juliuslipp commited on
Commit
660d301
1 Parent(s): c7902b4

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +25 -1
README.md CHANGED
@@ -2718,8 +2718,32 @@ console.log(cos_sim(truncated[0].data, truncated[1].data)); // 0.697953202142520
2718
 
2719
  ### Using API
2720
 
2721
- You’ll be able to use the models through our API as well. The API is coming soon and will have some exciting features. Stay tuned!
2722
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2723
 
2724
  ## Evaluation
2725
 
 
2718
 
2719
  ### Using API
2720
 
2721
+ You can use the Model via our API as follows.
2722
 
2723
+ ```python
2724
+ from mixedbread_ai.client import MixedbreadAI
2725
+ from sklearn.metrics.pairwise import cosine_similarity
2726
+ import os
2727
+
2728
+ mxbai = MixedbreadAI(api_key="{MIXEDBREAD_API_KEY}")
2729
+
2730
+ english_sentences = [
2731
+ 'What is the capital of Australia?',
2732
+ 'Canberra is the capital of Australia.'
2733
+ ]
2734
+
2735
+ res = mxbai.embeddings(
2736
+ input=english_sentences,
2737
+ model="mixedbread-ai/mxbai-embed-2d-large-v1",
2738
+ dimensions=512,
2739
+ )
2740
+ embeddings = [entry.embedding for entry in res.data]
2741
+
2742
+ similarities = cosine_similarity([embeddings[0]], [embeddings[1]])
2743
+ print(similarities)
2744
+ ```
2745
+
2746
+ The API comes with native INT8 and binary quantization support!
2747
 
2748
  ## Evaluation
2749