kevinhug commited on
Commit
c16e9f5
·
1 Parent(s): 8d7a1e9

multi class

Browse files
Files changed (2) hide show
  1. app.py +3 -1
  2. classify.py +5 -3
app.py CHANGED
@@ -63,6 +63,8 @@ Relevant offers encourage repeat visits and build long-term loyalty.
63
  - Inventory Optimization
64
  Promotes underperforming products or clears surplus stock with strategic recommendations.
65
 
 
 
66
  Marketing
67
  ------------
68
  - GraphRAG: Models customer-product relationship networks for next-best-action predictions
@@ -253,7 +255,7 @@ Allows downstream tasks (like sentiment analysis or topic modeling) to focus on
253
  Objective: Classify customer feedback into product bucket
254
  ================================================
255
  """)
256
- in_verbatim = gr.Textbox(label="Customer Feedback")
257
  out_product = gr.Textbox(label="Classification")
258
 
259
  gr.Examples(
 
63
  - Inventory Optimization
64
  Promotes underperforming products or clears surplus stock with strategic recommendations.
65
 
66
+ If you're experiencing declining market share or inefficiencies in your operations, here's how I can help:
67
+ ==============
68
  Marketing
69
  ------------
70
  - GraphRAG: Models customer-product relationship networks for next-best-action predictions
 
255
  Objective: Classify customer feedback into product bucket
256
  ================================================
257
  """)
258
+ in_verbatim = gr.Textbox(label="Customer Feedback separate by ;")
259
  out_product = gr.Textbox(label="Classification")
260
 
261
  gr.Examples(
classify.py CHANGED
@@ -22,20 +22,22 @@ client = instructor.from_openai(
22
  ),
23
  mode=instructor.Mode.JSON,
24
  )
 
 
25
  """
26
  llm = 'llama-3.1-8b-instant' if os.getenv("GROQ_API_KEY") else "deepseek-r1"
27
 
28
 
29
  class Tag(BaseModel):
30
 
31
- chain_of_thought:List[str]= Field(default_factory=list, description="the chain of thought led to the prediction", examples=["Let's think step by step. the customer explicitly mention donation, and there is a tag name with donation, tag the text with donation"])
32
  name: str
33
  id: int= Field(..., description="id for the specific tag")
34
  confidence: float = Field(
35
  default=0.5,
36
  ge=0,
37
  le=1,
38
- description="The confidence of the prediction for name and id, 0 is low, 1 is high",examples=[0.5,0.1,0.9]
39
  )
40
 
41
  @field_validator('confidence', mode="after")
@@ -157,7 +159,7 @@ texts = """
157
  """
158
 
159
  def bucket(texts):
160
- texts=texts.split(";")
161
  request = TagRequest(texts=texts, tags=tags)
162
 
163
  response = asyncio.run(tag_request(request))
 
22
  ),
23
  mode=instructor.Mode.JSON,
24
  )
25
+
26
+ chain_of_thought:List[str]= Field(default_factory=list, description="the chain of thought led to the prediction", examples=["Let's think step by step. the customer explicitly mention donation, and there is a tag name with donation, tag the text with donation"])
27
  """
28
  llm = 'llama-3.1-8b-instant' if os.getenv("GROQ_API_KEY") else "deepseek-r1"
29
 
30
 
31
  class Tag(BaseModel):
32
 
33
+
34
  name: str
35
  id: int= Field(..., description="id for the specific tag")
36
  confidence: float = Field(
37
  default=0.5,
38
  ge=0,
39
  le=1,
40
+ description="The confidence of the prediction(id, name) for the text, 0 is low, 1 is high",examples=[0.5,0.1,0.9]
41
  )
42
 
43
  @field_validator('confidence', mode="after")
 
159
  """
160
 
161
  def bucket(texts):
162
+ texts=map(lambda t: t.strip(), texts.split(";"))
163
  request = TagRequest(texts=texts, tags=tags)
164
 
165
  response = asyncio.run(tag_request(request))