Feature Extraction
Transformers
Safetensors
sentence-transformers
Chinese
English
c2llm
code
custom_code
Instructions to use codefuse-ai/C2LLM-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use codefuse-ai/C2LLM-7B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="codefuse-ai/C2LLM-7B", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("codefuse-ai/C2LLM-7B", trust_remote_code=True, dtype="auto") - sentence-transformers
How to use codefuse-ai/C2LLM-7B with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("codefuse-ai/C2LLM-7B", trust_remote_code=True) sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -73,7 +73,10 @@ embeddings = model.encode(sentences)
|
|
| 73 |
from sentence_transformers import SentenceTransformer
|
| 74 |
|
| 75 |
# Load the model
|
| 76 |
-
model = SentenceTransformer("codefuse-ai/C2LLM-7B", trust_remote_code=True)
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
# Prepare the data
|
| 79 |
sentences = ['''int r = (int) params >> 8 & 0xff;
|
|
@@ -102,6 +105,8 @@ return new RangeInfo(inclusive ? tempTo : tempTo + 1, tempFrom + 1, true);
|
|
| 102 |
return new RangeInfo(tempFrom, inclusive ? tempTo + 1 : tempTo, false);
|
| 103 |
}''']
|
| 104 |
|
|
|
|
|
|
|
| 105 |
# Get the embeddings
|
| 106 |
embeddings = model.encode(sentences)
|
| 107 |
```
|
|
|
|
| 73 |
from sentence_transformers import SentenceTransformer
|
| 74 |
|
| 75 |
# Load the model
|
| 76 |
+
model = SentenceTransformer("codefuse-ai/C2LLM-7B", trust_remote_code=True, tokenizer_kwargs={"padding_side":"left"})
|
| 77 |
+
|
| 78 |
+
# Prepare the instruction
|
| 79 |
+
instruction = "xxxxx"
|
| 80 |
|
| 81 |
# Prepare the data
|
| 82 |
sentences = ['''int r = (int) params >> 8 & 0xff;
|
|
|
|
| 105 |
return new RangeInfo(tempFrom, inclusive ? tempTo + 1 : tempTo, false);
|
| 106 |
}''']
|
| 107 |
|
| 108 |
+
sentences = [instruction+sentence for sentence in sentences]
|
| 109 |
+
|
| 110 |
# Get the embeddings
|
| 111 |
embeddings = model.encode(sentences)
|
| 112 |
```
|