You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docs/examples/examples/product_recommendation.md
+29-30Lines changed: 29 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,9 +29,9 @@ Product taxonomy is a way to organize product catalogs in a logical and hierarch
29
29
30
30
## Prerequisites
31
31
32
-
*[Install PostgreSQL](https://cocoindex.io/docs/getting_started/installation#-install-postgres). CocoIndex uses PostgreSQL internally for incremental processing.
32
+
-[Install PostgreSQL](https://cocoindex.io/docs/getting_started/installation#-install-postgres). CocoIndex uses PostgreSQL internally for incremental processing.
33
33
-[Install Neo4j](https://cocoindex.io/docs/targets/neo4j), a graph database.
34
-
--[Configure your OpenAI API key](https://cocoindex.io/docs/ai/llm#openai). Create a `.env` file from `.env.example`, and fill `OPENAI_API_KEY`.
34
+
-[Configure your OpenAI API key](https://cocoindex.io/docs/ai/llm#openai). Create a `.env` file from `.env.example`, and fill `OPENAI_API_KEY`.
35
35
36
36
Alternatively, we have native support for Gemini, Ollama, LiteLLM. You can choose your favorite LLM provider and work completely on-premises.
37
37
@@ -134,44 +134,43 @@ It performs the following transformations:
134
134
135
135
### Product Taxonomy Definition
136
136
137
-
Since we are using LLM to extract product taxonomy, we need to provide a detailed instruction at the class-level docstring.
137
+
Since we are using LLM to extract product taxonomy, we need to provide a detailed instruction at the field-level description.
138
138
139
139
```python
140
-
@dataclasses.dataclass
141
-
classProductTaxonomy:
142
-
"""
143
-
Taxonomy for the product.
144
-
145
-
A taxonomy is a concise noun (or short noun phrase), based on its core functionality, without specific details such as branding, style, etc.
146
-
147
-
Always use the most common words in US English.
148
-
149
-
Use lowercase without punctuation, unless it's a proper noun or acronym.
150
-
151
-
A product may have multiple taxonomies. Avoid large categories like "office supplies" or "electronics". Use specific ones, like "pen" or "printer".
152
-
"""
153
-
name: str
140
+
classProductTaxonomy(BaseModel):
141
+
"""
142
+
Taxonomy for the product.
143
+
"""
144
+
145
+
name: str= Field(
146
+
description="A taxonomy is a concise noun (or short noun phrase), based on its core functionality, "
147
+
"without specific details such as branding, style, etc. Always use the most common words in US "
148
+
"English. Use lowercase without punctuation, unless it's a proper noun or acronym. A product may "
149
+
"have multiple taxonomies. Avoid large categories like 'office supplies' or 'electronics'. Use "
150
+
"specific ones, like 'pen' or 'printer'."
151
+
)
154
152
```
155
153
156
154
### Define Product Taxonomy Info
157
155
158
-
Basically we want to extract all possible taxonomies for a product, and think about what other products are likely to be bought together with the current product.
156
+
Basically, we want to extract all possible taxonomies for a product and think about what other products are likely to be bought together with the current product.
159
157
160
158
```python
161
-
@dataclasses.dataclass
162
-
classProductTaxonomyInfo:
163
-
"""
164
-
Taxonomy information for the product.
165
-
166
-
Fields:
167
-
- taxonomies: Taxonomies for the current product.
168
-
- complementary_taxonomies: Think about when customers buy this product, what else they might need as complementary products. Put labels for these complentary products.
"Think about when customers buy this product, what else they might need as complementary products. Put labels "
169
+
"for these complementary products."
170
+
)
172
171
```
173
172
174
-
For each product, we want some insight about its taxonomy and complementary taxonomy and we could use that as bridge to find related product using knowledge graph.
173
+
For each product, we want some insight about its taxonomy and complementary taxonomy, and we could use that as a bridge to find a related product using the knowledge graph.
0 commit comments