mehran-sarmadi commited on
Commit
645e9e7
·
verified ·
1 Parent(s): bdaab2c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +22 -16
README.md CHANGED
@@ -91,7 +91,7 @@ import json
91
 
92
  # --- Configuration ---
93
  API_KEY = "your_api_key" # Replace with your API key or "mcinext" for testing
94
- API_URL = "http://your-server-address/api/embedding-model"
95
 
96
  # --- Request Details ---
97
  headers = {
@@ -127,33 +127,36 @@ except Exception as err:
127
  ```
128
 
129
  3. Handling Special Tasks
130
- STS (Semantic Textual Similarity)
131
- For STS tasks, you need to compare the similarity between two pieces of text. To do this:
132
 
133
- Send the first sentence with the sts.sent1 prompt type.
134
-
135
- Send the second sentence with the sts.sent2 prompt type.
136
 
137
  Here’s how to do this:
138
 
139
- Request 1: First sentence (sts.sent1):
140
 
141
  ```json
142
  {
143
  "model": "Hakim",
144
  "input": [
145
- "This is the first sentence."
 
146
  ],
147
  "prompt_type": "sts.sent1"
148
  }
149
  ```
150
- Request 2: Second sentence (sts.sent2):
 
 
151
 
152
  ```json
153
  {
154
  "model": "Hakim",
155
  "input": [
156
- "This is the second sentence."
 
157
  ],
158
  "prompt_type": "sts.sent2"
159
  }
@@ -163,13 +166,15 @@ Both requests will return embeddings for the respective sentences. You can then
163
  Retrieval
164
  For retrieval tasks, you need to compare a query to multiple documents. You need to send two different types of requests:
165
 
 
166
  Query Embedding (retrieval.query):
167
 
168
  ```json
169
  {
170
  "model": "Hakim",
171
  "input": [
172
- "What is the capital of France?"
 
173
  ],
174
  "prompt_type": "retrieval.query"
175
  }
@@ -181,13 +186,14 @@ Document Embedding (retrieval.passage):
181
  {
182
  "model": "Hakim",
183
  "input": [
184
- "Paris is the capital of France."
 
185
  ],
186
  "prompt_type": "retrieval.passage"
187
  }
188
  ```
189
 
190
- This way, you can compare the query embedding to the document embedding to check if they are related or similar. The model will return embeddings for both the query and the document, and you can compute their similarity.
191
 
192
  Cross Task
193
  The cross task is used when you want to perform a binary classification or categorization based on the embeddings of two related texts. For example, given two sentences, you might want to categorize them into different categories (e.g., "similar" or "dissimilar").
@@ -198,14 +204,14 @@ For this, you provide both texts in a specific format:
198
  {
199
  "model": "Hakim",
200
  "input": [
201
- "[text1]: This is the first text, [text2]: This is the second text"
 
202
  ],
203
  "prompt_type": "cross"
204
  }
205
  ```
206
 
207
- The model will process both texts, compute their embeddings, and then categorize or classify them into predefined categories based on the similarity or relationship between the two texts.
208
-
209
  4. Error Handling
210
  If the input is incorrect or the prompt type is invalid, the API will return a 400 Bad Request with a detailed error message. For example:
211
 
 
91
 
92
  # --- Configuration ---
93
  API_KEY = "your_api_key" # Replace with your API key or "mcinext" for testing
94
+ API_URL = "http://mcinext.ai/api/embedding-model"
95
 
96
  # --- Request Details ---
97
  headers = {
 
127
  ```
128
 
129
  3. Handling Special Tasks
130
+ ### STS (Semantic Textual Similarity)
131
+ For STS tasks, you need to compare the similarity between two pieces of text. You can send one or more sentences for comparison. To do this:
132
 
133
+ 1. Send the first sentence(s) with the `sts.sent1` prompt type.
134
+ 2. Send the second sentence(s) with the `sts.sent2` prompt type.
 
135
 
136
  Here’s how to do this:
137
 
138
+ **Request 1:** First sentence(s) (`sts.sent1`):
139
 
140
  ```json
141
  {
142
  "model": "Hakim",
143
  "input": [
144
+ "This is the first sentence.",
145
+ "This is another first sentence."
146
  ],
147
  "prompt_type": "sts.sent1"
148
  }
149
  ```
150
+
151
+ Request 2: Second sentence(s) (sts.sent2):
152
+
153
 
154
  ```json
155
  {
156
  "model": "Hakim",
157
  "input": [
158
+ "This is the second sentence.",
159
+ "This is another second sentence."
160
  ],
161
  "prompt_type": "sts.sent2"
162
  }
 
166
  Retrieval
167
  For retrieval tasks, you need to compare a query to multiple documents. You need to send two different types of requests:
168
 
169
+
170
  Query Embedding (retrieval.query):
171
 
172
  ```json
173
  {
174
  "model": "Hakim",
175
  "input": [
176
+ "What is the capital of France?",
177
+ "What is the population of France?"
178
  ],
179
  "prompt_type": "retrieval.query"
180
  }
 
186
  {
187
  "model": "Hakim",
188
  "input": [
189
+ "Paris is the capital of France.",
190
+ "Paris has a population of over 2 million."
191
  ],
192
  "prompt_type": "retrieval.passage"
193
  }
194
  ```
195
 
196
+ This way, you can compare the query embeddings to the document embeddings to check if they are related or similar. The model will return embeddings for both the query and the document, and you can compute their similarity.
197
 
198
  Cross Task
199
  The cross task is used when you want to perform a binary classification or categorization based on the embeddings of two related texts. For example, given two sentences, you might want to categorize them into different categories (e.g., "similar" or "dissimilar").
 
204
  {
205
  "model": "Hakim",
206
  "input": [
207
+ "[text1]: This is the first text, [text2]: This is the second text",
208
+ "[text1]: A new sentence, [text2]: Another different sentence"
209
  ],
210
  "prompt_type": "cross"
211
  }
212
  ```
213
 
214
+ The model will process both pairs of texts, compute their embeddings, and then you can use these embeddings to train a model to categorize or classify them into predefined categories based on the similarity or relationship between the two texts.
 
215
  4. Error Handling
216
  If the input is incorrect or the prompt type is invalid, the API will return a 400 Bad Request with a detailed error message. For example:
217