surazbhandari commited on
Commit
0fbb74d
·
verified ·
1 Parent(s): f6d232c

Sync from GitHub Actions

Browse files
Files changed (1) hide show
  1. README.md +13 -8
README.md CHANGED
@@ -45,13 +45,21 @@ streamlit run app.py
45
 
46
  ## Usage
47
 
48
- You can use the provided `src` library to run inference in your own Python scripts:
49
 
50
  ```python
51
- from src.inference import EmbeddingInference
 
 
 
 
52
 
53
- # Load model from current directory
54
- model = EmbeddingInference.from_pretrained(".")
 
 
 
 
55
 
56
  # Define two product titles
57
  product_a = "Sony WH-1000XM5 Wireless Noise Canceling Headphones, Black"
@@ -60,10 +68,7 @@ product_b = "Sony WH1000XM5/B Headphones"
60
  # Calculate similarity (0 to 1)
61
  score = model.similarity(product_a, product_b)
62
 
63
- if score > 0.82:
64
- print(f"It's a match! (Score: {score:.4f})")
65
- else:
66
- print(f"Different products. (Score: {score:.4f})")
67
  ```
68
 
69
  ## Automated Sync
 
45
 
46
  ## Usage
47
 
48
+ Since this is a custom model, you need to download the code and weights from the Hub:
49
 
50
  ```python
51
+ from huggingface_hub import snapshot_download
52
+ import sys
53
+
54
+ # 1. Download model (one-time)
55
+ model_dir = snapshot_download("surazbhandari/miniembed-product")
56
 
57
+ # 2. Add to path so we can import 'src'
58
+ sys.path.insert(0, model_dir)
59
+
60
+ # 3. Load Model
61
+ from src.inference import EmbeddingInference
62
+ model = EmbeddingInference.from_pretrained(model_dir)
63
 
64
  # Define two product titles
65
  product_a = "Sony WH-1000XM5 Wireless Noise Canceling Headphones, Black"
 
68
  # Calculate similarity (0 to 1)
69
  score = model.similarity(product_a, product_b)
70
 
71
+ print(f"Similarity: {score:.4f}")
 
 
 
72
  ```
73
 
74
  ## Automated Sync