michaelfeil commited on
Commit
515fb9b
1 Parent(s): 5de1236

Upload intfloat/e5-small ctranslate fp16 weights

Browse files
Files changed (1) hide show
  1. README.md +24 -4
README.md CHANGED
@@ -2608,17 +2608,37 @@ Speedup inference while reducing memory by 2x-4x using int8 inference in C++ on
2608
 
2609
  quantized version of [intfloat/e5-small](https://huggingface.co/intfloat/e5-small)
2610
  ```bash
2611
- pip install hf-hub-ctranslate2>=3.0.0 ctranslate2>=3.16.0
2612
  ```
2613
 
2614
  ```python
2615
  # from transformers import AutoTokenizer
2616
  model_name = "michaelfeil/ct2fast-e5-small"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2617
 
2618
  from hf_hub_ctranslate2 import CT2SentenceTransformer
2619
  model = CT2SentenceTransformer(
2620
- model_name, compute_type="int8_float16", device="cuda",
2621
- repo_contains_ct2=True
2622
  )
2623
  embeddings = model.encode(
2624
  ["I like soccer", "I like tennis", "The eiffel tower is in Paris"],
@@ -2632,7 +2652,7 @@ scores = (embeddings @ embeddings.T) * 100
2632
  ```
2633
 
2634
  Checkpoint compatible to [ctranslate2>=3.16.0](https://github.com/OpenNMT/CTranslate2)
2635
- and [hf-hub-ctranslate2>=3.0.0](https://github.com/michaelfeil/hf-hub-ctranslate2)
2636
  - `compute_type=int8_float16` for `device="cuda"`
2637
  - `compute_type=int8` for `device="cpu"`
2638
 
 
2608
 
2609
  quantized version of [intfloat/e5-small](https://huggingface.co/intfloat/e5-small)
2610
  ```bash
2611
+ pip install hf-hub-ctranslate2>=2.11.0 ctranslate2>=3.16.0
2612
  ```
2613
 
2614
  ```python
2615
  # from transformers import AutoTokenizer
2616
  model_name = "michaelfeil/ct2fast-e5-small"
2617
+ model_name_orig=intfloat/e5-small
2618
+
2619
+ from hf_hub_ctranslate2 import EncoderCT2fromHfHub
2620
+ model = EncoderCT2fromHfHub(
2621
+ # load in int8 on CUDA
2622
+ model_name_or_path=model_name,
2623
+ device="cuda",
2624
+ compute_type="int8_float16",
2625
+ )
2626
+ outputs = model.generate(
2627
+ text=["I like soccer", "I like tennis", "The eiffel tower is in Paris"],
2628
+ max_length=64,
2629
+ )
2630
+ # perform downstream tasks on outputs
2631
+ outputs["pooler_output"]
2632
+ outputs["last_hidden_state"]
2633
+ outputs["attention_mask"]
2634
+
2635
+ # alternative, use SentenceTransformer Mix-In
2636
+ # for end-to-end Sentence embeddings generation
2637
+ # not pulling from this repo
2638
 
2639
  from hf_hub_ctranslate2 import CT2SentenceTransformer
2640
  model = CT2SentenceTransformer(
2641
+ model_name_orig, compute_type="int8_float16", device="cuda",
 
2642
  )
2643
  embeddings = model.encode(
2644
  ["I like soccer", "I like tennis", "The eiffel tower is in Paris"],
 
2652
  ```
2653
 
2654
  Checkpoint compatible to [ctranslate2>=3.16.0](https://github.com/OpenNMT/CTranslate2)
2655
+ and [hf-hub-ctranslate2>=2.11.0](https://github.com/michaelfeil/hf-hub-ctranslate2)
2656
  - `compute_type=int8_float16` for `device="cuda"`
2657
  - `compute_type=int8` for `device="cpu"`
2658