Instructions to use vikp/reverse_instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use vikp/reverse_instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="vikp/reverse_instruct", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("vikp/reverse_instruct", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("vikp/reverse_instruct", trust_remote_code=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use vikp/reverse_instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "vikp/reverse_instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "vikp/reverse_instruct", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/vikp/reverse_instruct
- SGLang
How to use vikp/reverse_instruct 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 "vikp/reverse_instruct" \ --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": "vikp/reverse_instruct", "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 "vikp/reverse_instruct" \ --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": "vikp/reverse_instruct", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use vikp/reverse_instruct with Docker Model Runner:
docker model run hf.co/vikp/reverse_instruct
Update README.md
Browse files
README.md
CHANGED
|
@@ -7,28 +7,28 @@ This model will generate instructions given some text. It is useful for labelli
|
|
| 7 |
|
| 8 |
It was trained across the [reverse-instruct](https://huggingface.co/vikp/reverse_instruct) dataset for 2 epochs. Final validation loss was .72, with rouge-l of .66 .
|
| 9 |
|
| 10 |
-
Here is an inference example:
|
| 11 |
|
| 12 |
```
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
model = AutoModelForCausalLM.from_pretrained("vikp/reverse_instruct")
|
| 16 |
-
tokenizer = AutoTokenizer.from_pretrained("vikp/reverse_instruct")
|
| 17 |
-
|
| 18 |
-
prompt = """
|
| 19 |
Output
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
======
|
| 24 |
Instruction
|
| 25 |
|
| 26 |
-
""".
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
inputs = tokenizer(prompt, return_tensors="pt")
|
| 29 |
outputs = model.generate(**inputs, max_new_tokens=512)
|
| 30 |
texts = tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
|
|
|
| 31 |
print(texts)
|
| 32 |
```
|
| 33 |
|
| 34 |
-
And the output instruction for the above example would be `
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
It was trained across the [reverse-instruct](https://huggingface.co/vikp/reverse_instruct) dataset for 2 epochs. Final validation loss was .72, with rouge-l of .66 .
|
| 9 |
|
| 10 |
+
Here is an inference example, with some random text from falcon-refinedweb:
|
| 11 |
|
| 12 |
```
|
| 13 |
+
template = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
Output
|
| 15 |
|
| 16 |
+
{output}
|
|
|
|
| 17 |
======
|
| 18 |
Instruction
|
| 19 |
|
| 20 |
+
""".lstrip()
|
| 21 |
+
|
| 22 |
+
text = "Many of the programmers, engineers and developers we talk to have a secret that they don't reveal until they know people pretty well. No, I'm not talking about the complete set of Star Wars playing cards they have stashed in the basement or the Rush LPs they haven't gotten around to trading in yet. I'm talking about Legos. You remember Legos, those infinitely malleable blocks that children around the world use to construct everything from tiny towers to life-size towers. Perhaps because these toys leave so much to the imagination, they've captured the imagination of a generation of tech workers. The appearance of Lego in Douglas Copeland's novel Microserfs, set on the Microsoft corporate campus, is one example of how pervasive it is."
|
| 23 |
+
prompt = template.format(output=text)
|
| 24 |
|
| 25 |
inputs = tokenizer(prompt, return_tensors="pt")
|
| 26 |
outputs = model.generate(**inputs, max_new_tokens=512)
|
| 27 |
texts = tokenizer.batch_decode(outputs, skip_special_tokens=True)
|
| 28 |
+
texts = [t.replace(template, "") for t in texts]
|
| 29 |
print(texts)
|
| 30 |
```
|
| 31 |
|
| 32 |
+
And the output instruction for the above example would be `What is a secret that many programmers, engineers and developers don't reveal until they know people pretty well?`
|
| 33 |
+
|
| 34 |
+
It works with code, too, although llama-7b is undertrained on code.
|