Yuki131 commited on
Commit
24c69e9
·
verified ·
1 Parent(s): d2a21c2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +39 -9
README.md CHANGED
@@ -67,7 +67,7 @@ KeyError: 'qwen2'
67
  ```
68
 
69
  ## Usage
70
-
71
  Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
72
 
73
  ```
@@ -120,12 +120,42 @@ embeddings = model.encode(
120
  print(embeddings)
121
  ```
122
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  ## Citation
124
  If you find this model useful, please consider giving a star and citation.
125
  ```
126
  @misc{zhao2025kalmembeddingv2,
127
  title={KaLM-Embedding-V2: Superior Training Techniques and Data Inspire A Versatile Embedding Model},
128
- author={Xinping Zhao and Xinshuo Hu and Zifei Shan and Shouzheng Huang and Yao Zhou and Zetian Sun and Zhenyu Liu and Dongfang Li and Xinyuan Wei and Qian Chen and Youcheng Pan and Yang Xiang and Meishan Zhang and Haofen Wang and Jun Yu and Baotian Hu and Min Zhang},
129
  year={2025},
130
  eprint={2506.20923},
131
  archivePrefix={arXiv},
@@ -134,13 +164,13 @@ If you find this model useful, please consider giving a star and citation.
134
  }
135
 
136
  @misc{hu2025kalmembedding,
137
- title={KaLM-Embedding: Superior Training Data Brings A Stronger Embedding Model},
138
- author={Xinshuo Hu and Zifei Shan and Xinping Zhao and Zetian Sun and Zhenyu Liu and Dongfang Li and Shaolin Ye and Xinyuan Wei and Qian Chen and Baotian Hu and Haofen Wang and Jun Yu and Min Zhang},
139
- year={2025},
140
- eprint={2501.01028},
141
- archivePrefix={arXiv},
142
- primaryClass={cs.CL},
143
- url={https://arxiv.org/abs/2501.01028},
144
  }
145
  ```
146
 
 
67
  ```
68
 
69
  ## Usage
70
+ ### sentence-transformers support
71
  Using this model becomes easy when you have [sentence-transformers](https://www.SBERT.net) installed:
72
 
73
  ```
 
120
  print(embeddings)
121
  ```
122
 
123
+ ### vllm support
124
+ ```
125
+ pip install -U vllm==0.8.5
126
+ ```
127
+ ```python
128
+ import torch
129
+ import vllm
130
+ from vllm import LLM
131
+ def get_detailed_instruct(task_description: str, query: str) -> str:
132
+ return f'Instruct: {task_description}\nQuery:{query}'
133
+
134
+ task = 'Given a query, retrieve documents that answer the query'
135
+ queries = [
136
+ get_detailed_instruct(task, 'What is the capital of China?'),
137
+ get_detailed_instruct(task, 'Explain gravity')
138
+ ]
139
+ documents = [
140
+ "The capital of China is Beijing.",
141
+ "Gravity is a force that attracts two bodies towards each other. It gives weight to physical objects and is responsible for the movement of planets around the sun."
142
+ ]
143
+ input_texts = queries + documents
144
+
145
+ model = LLM(model="{MODEL_NAME_OR_PATH}", task="embed", trust_remote_code=True, dtype="float16")
146
+
147
+ outputs = model.embed(input_texts)
148
+ embeddings = torch.tensor([o.outputs.embedding for o in outputs])
149
+ scores = (embeddings[:2] @ embeddings[2:].T)
150
+ print(scores.tolist())
151
+ ```
152
+
153
  ## Citation
154
  If you find this model useful, please consider giving a star and citation.
155
  ```
156
  @misc{zhao2025kalmembeddingv2,
157
  title={KaLM-Embedding-V2: Superior Training Techniques and Data Inspire A Versatile Embedding Model},
158
+ author={Xinping Zhao and Xinshuo Hu and Zifei Shan and Shouzheng Huang and Yao Zhou and Xin Zhang and Zetian Sun and Zhenyu Liu and Dongfang Li and Xinyuan Wei and Youcheng Pan and Yang Xiang and Meishan Zhang and Haofen Wang and Jun Yu and Baotian Hu and Min Zhang},
159
  year={2025},
160
  eprint={2506.20923},
161
  archivePrefix={arXiv},
 
164
  }
165
 
166
  @misc{hu2025kalmembedding,
167
+ title={KaLM-Embedding: Superior Training Data Brings A Stronger Embedding Model},
168
+ author={Xinshuo Hu and Zifei Shan and Xinping Zhao and Zetian Sun and Zhenyu Liu and Dongfang Li and Shaolin Ye and Xinyuan Wei and Qian Chen and Baotian Hu and Haofen Wang and Jun Yu and Min Zhang},
169
+ year={2025},
170
+ eprint={2501.01028},
171
+ archivePrefix={arXiv},
172
+ primaryClass={cs.CL},
173
+ url={https://arxiv.org/abs/2501.01028},
174
  }
175
  ```
176