Instructions to use BigSalmon/Infill with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use BigSalmon/Infill with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="BigSalmon/Infill")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("BigSalmon/Infill") model = AutoModelForCausalLM.from_pretrained("BigSalmon/Infill") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use BigSalmon/Infill with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "BigSalmon/Infill" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "BigSalmon/Infill", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/BigSalmon/Infill
- SGLang
How to use BigSalmon/Infill with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "BigSalmon/Infill" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "BigSalmon/Infill", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "BigSalmon/Infill" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "BigSalmon/Infill", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use BigSalmon/Infill with Docker Model Runner:
docker model run hf.co/BigSalmon/Infill
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
```
|
| 2 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 3 |
+
|
| 4 |
+
tokenizer = AutoTokenizer.from_pretrained("BigSalmon/Infill")
|
| 5 |
+
|
| 6 |
+
model = AutoModelForCausalLM.from_pretrained("BigSalmon/Infill")
|
| 7 |
+
```
|
| 8 |
+
|
| 9 |
+
```
|
| 10 |
+
Demo:
|
| 11 |
+
https://huggingface.co/spaces/BigSalmon/FormalInformalConciseWordy
|
| 12 |
+
```
|
| 13 |
+
|
| 14 |
+
```
|
| 15 |
+
prompt = """informal english: corn fields are all across illinois, visible once you leave chicago.\nTranslated into the Style of Abraham Lincoln:"""
|
| 16 |
+
input_ids = tokenizer.encode(prompt, return_tensors='pt')
|
| 17 |
+
outputs = model.generate(input_ids=input_ids,
|
| 18 |
+
max_length=10 + len(prompt),
|
| 19 |
+
temperature=1.0,
|
| 20 |
+
top_k=50,
|
| 21 |
+
top_p=0.95,
|
| 22 |
+
do_sample=True,
|
| 23 |
+
num_return_sequences=5,
|
| 24 |
+
early_stopping=True)
|
| 25 |
+
for i in range(5):
|
| 26 |
+
print(tokenizer.decode(outputs[i]))
|
| 27 |
+
```
|
| 28 |
+
Most likely outputs (Disclaimer: I highly recommend using this over just generating):
|
| 29 |
+
```
|
| 30 |
+
prompt = """informal english: corn fields are all across illinois, visible once you leave chicago.\nTranslated into the Style of Abraham Lincoln:"""
|
| 31 |
+
text = tokenizer.encode(prompt)
|
| 32 |
+
myinput, past_key_values = torch.tensor([text]), None
|
| 33 |
+
myinput = myinput
|
| 34 |
+
myinput= myinput.to(device)
|
| 35 |
+
logits, past_key_values = model(myinput, past_key_values = past_key_values, return_dict=False)
|
| 36 |
+
logits = logits[0,-1]
|
| 37 |
+
probabilities = torch.nn.functional.softmax(logits)
|
| 38 |
+
best_logits, best_indices = logits.topk(250)
|
| 39 |
+
best_words = [tokenizer.decode([idx.item()]) for idx in best_indices]
|
| 40 |
+
text.append(best_indices[0].item())
|
| 41 |
+
best_probabilities = probabilities[best_indices].tolist()
|
| 42 |
+
words = []
|
| 43 |
+
print(best_words)
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
Infill / Infilling / Masking / Phrase Masking
|
| 47 |
+
|
| 48 |
+
```
|
| 49 |
+
his contention [blank] by the evidence [sep] was refuted [answer]
|
| 50 |
+
|
| 51 |
+
***
|
| 52 |
+
|
| 53 |
+
few sights are as [blank] new york city as the colorful, flashing signage of its bodegas [sep] synonymous with [answer]
|
| 54 |
+
|
| 55 |
+
***
|
| 56 |
+
|
| 57 |
+
when rick won the lottery, all of his distant relatives [blank] his winnings [sep] clamored for [answer]
|
| 58 |
+
|
| 59 |
+
***
|
| 60 |
+
|
| 61 |
+
the library’s quiet atmosphere encourages visitors to [blank] in their work [sep] immerse themselves [answer]
|
| 62 |
+
|
| 63 |
+
***
|
| 64 |
+
```
|