Files changed (1) hide show
  1. README.md +4 -91
README.md CHANGED
@@ -40,7 +40,7 @@ language:
40
  ## Usage
41
 
42
  <details>
43
- <summary>Via API (Standard Embeddings)</summary>
44
 
45
  ```bash
46
  curl -X POST https://api.perplexity.ai/v1/embeddings \
@@ -60,73 +60,6 @@ curl -X POST https://api.perplexity.ai/v1/embeddings \
60
 
61
  </details>
62
 
63
- <details>
64
- <summary>Via API (Contextualized Embeddings)</summary>
65
-
66
- ```bash
67
- curl -X POST https://api.perplexity.ai/v1/contextualizedembeddings \
68
- -H "Authorization: Bearer YOUR_API_KEY" \
69
- -H "Content-Type: application/json" \
70
- -d '{
71
- "inputs": [
72
- [
73
- "Curiosity begins in childhood with endless questions about the world.",
74
- "As we grow, curiosity drives us to explore new ideas and challenge assumptions.",
75
- "Scientific breakthroughs often start with a simple curious question."
76
- ],
77
- [
78
- "The curiosity rover explores Mars, searching for signs of ancient life.",
79
- "Each discovery on Mars sparks new questions about our place in the universe."
80
- ]
81
- ],
82
- "model": "pplx-embed-1-context-4B"
83
- }'
84
- ```
85
-
86
- </details>
87
-
88
- <details>
89
- <summary>Using Transformers</summary>
90
-
91
- ```python
92
- from transformers import AutoModel
93
-
94
- model = AutoModel.from_pretrained(
95
- "perplexity-ai/pplx-embed-1-0.6B",
96
- trust_remote_code=True
97
- )
98
- texts = [
99
- "Scientists explore the universe driven by curiosity.",
100
- "Children learn through curious exploration.",
101
- "Historical discoveries began with curious questions.",
102
- "Animals use curiosity to adapt and survive.",
103
- "Philosophy examines the nature of curiosity.",
104
- ]
105
-
106
- embeddings = model.encode(texts) # Shape: (5, 1024)
107
-
108
- model_ctx = AutoModel.from_pretrained(
109
- "perplexity-ai/pplx-embed-1-context-0.6B",
110
- trust_remote_code=True
111
- )
112
-
113
- doc_chunks = [
114
- [
115
- "Curiosity begins in childhood with endless questions about the world.",
116
- "As we grow, curiosity drives us to explore new ideas.",
117
- "Scientific breakthroughs often start with a curious question."
118
- ],
119
- [
120
- "The curiosity rover explores Mars searching for ancient life.",
121
- "Each discovery on Mars sparks new questions about the universe."
122
- ]
123
- ]
124
- # Returns list of numpy arrays (one per document)
125
- # embeddings[0].shape = (3, 1024), embeddings[1].shape = (2, 1024)
126
- embeddings = model_ctx.encode(doc_chunks)
127
- ```
128
-
129
- </details>
130
 
131
  <details>
132
  <summary>Using SentenceTransformers</summary>
@@ -135,7 +68,7 @@ embeddings = model_ctx.encode(doc_chunks)
135
  from sentence_transformers import SentenceTransformer
136
 
137
  model = SentenceTransformer(
138
- "perplexity-ai/pplx-embed-1-0.6B",
139
  trust_remote_code=True
140
  )
141
 
@@ -147,32 +80,12 @@ texts = [
147
  "Philosophy examines the nature of curiosity.",
148
  ]
149
 
150
- embeddings = model.encode(texts) # Shape: (5, 1024)
151
-
152
- model_ctx = SentenceTransformer(
153
- "perplexity-ai/pplx-embed-1-context-0.6B",
154
- trust_remote_code=True
155
- )
156
-
157
- doc_chunks = [
158
- [
159
- "Curiosity begins in childhood with endless questions about the world.",
160
- "As we grow, curiosity drives us to explore new ideas.",
161
- "Scientific breakthroughs often start with a curious question."
162
- ],
163
- [
164
- "The curiosity rover explores Mars searching for ancient life.",
165
- "Each discovery on Mars sparks new questions about the universe."
166
- ]
167
- ]
168
- # Returns list of numpy arrays (one per document)
169
- # embeddings[0].shape = (3, 1024), embeddings[1].shape = (2, 1024)
170
- embeddings = model_ctx.encode(doc_chunks)
171
  ```
172
 
173
  </details>
174
 
175
- </details>
176
 
177
  ## Technical Details
178
 
 
40
  ## Usage
41
 
42
  <details>
43
+ <summary>Via API</summary>
44
 
45
  ```bash
46
  curl -X POST https://api.perplexity.ai/v1/embeddings \
 
60
 
61
  </details>
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
  <details>
65
  <summary>Using SentenceTransformers</summary>
 
68
  from sentence_transformers import SentenceTransformer
69
 
70
  model = SentenceTransformer(
71
+ "perplexity-ai/pplx-embed-1-4B",
72
  trust_remote_code=True
73
  )
74
 
 
80
  "Philosophy examines the nature of curiosity.",
81
  ]
82
 
83
+ embeddings = model.encode(texts) # Shape: (5, 2560), quantized to int8
84
+ embeddings = model.encode(texts, quantization="binary") # Shape: (5, 2560), quantized to binary
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  ```
86
 
87
  </details>
88
 
 
89
 
90
  ## Technical Details
91