Instructions to use TroyDoesAI/BlackSheep-Llama3.2-3B-Context_Obedient with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use TroyDoesAI/BlackSheep-Llama3.2-3B-Context_Obedient with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="TroyDoesAI/BlackSheep-Llama3.2-3B-Context_Obedient") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("TroyDoesAI/BlackSheep-Llama3.2-3B-Context_Obedient") model = AutoModelForCausalLM.from_pretrained("TroyDoesAI/BlackSheep-Llama3.2-3B-Context_Obedient") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use TroyDoesAI/BlackSheep-Llama3.2-3B-Context_Obedient with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "TroyDoesAI/BlackSheep-Llama3.2-3B-Context_Obedient" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TroyDoesAI/BlackSheep-Llama3.2-3B-Context_Obedient", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/TroyDoesAI/BlackSheep-Llama3.2-3B-Context_Obedient
- SGLang
How to use TroyDoesAI/BlackSheep-Llama3.2-3B-Context_Obedient 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 "TroyDoesAI/BlackSheep-Llama3.2-3B-Context_Obedient" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TroyDoesAI/BlackSheep-Llama3.2-3B-Context_Obedient", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "TroyDoesAI/BlackSheep-Llama3.2-3B-Context_Obedient" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TroyDoesAI/BlackSheep-Llama3.2-3B-Context_Obedient", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio new
How to use TroyDoesAI/BlackSheep-Llama3.2-3B-Context_Obedient with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for TroyDoesAI/BlackSheep-Llama3.2-3B-Context_Obedient to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for TroyDoesAI/BlackSheep-Llama3.2-3B-Context_Obedient to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for TroyDoesAI/BlackSheep-Llama3.2-3B-Context_Obedient to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="TroyDoesAI/BlackSheep-Llama3.2-3B-Context_Obedient", max_seq_length=2048, ) - Docker Model Runner
How to use TroyDoesAI/BlackSheep-Llama3.2-3B-Context_Obedient with Docker Model Runner:
docker model run hf.co/TroyDoesAI/BlackSheep-Llama3.2-3B-Context_Obedient
Uploaded model
- Developed by: TroyDoesAI
- License: apache-2.0
- Finetuned from model : TroyDoesAI/BlackSheep-Llama3.2-3B
This llama model was trained 2x faster with Unsloth and Huggingface's TRL library.
Overview This model is meant to enhance adherence to provided context (e.g., for RAG applications) and reduce hallucinations, inspired by airoboros context-obedient question answer format.
Contextual DPO
Overview
The format for a contextual prompt is as follows:
BEGININPUT
BEGINCONTEXT
[key0: value0]
[key1: value1]
... other metdata ...
ENDCONTEXT
[insert your text blocks here]
ENDINPUT
[add as many other blocks, in the exact same format]
BEGININSTRUCTION
[insert your instruction(s). The model was tuned with single questions, paragraph format, lists, etc.]
ENDINSTRUCTION
I know it's a bit verbose and annoying, but after much trial and error, using these explicit delimiters helps the model understand where to find the responses and how to associate specific sources with it.
BEGININPUT- denotes a new input blockBEGINCONTEXT- denotes the block of context (metadata key/value pairs) to associate with the current input blockENDCONTEXT- denotes the end of the metadata block for the current input- [text] - Insert whatever text you want for the input block, as many paragraphs as can fit in the context.
ENDINPUT- denotes the end of the current input block- [repeat as many input blocks in this format as you want]
BEGININSTRUCTION- denotes the start of the list (or one) instruction(s) to respond to for all of the input blocks above.- [instruction(s)]
ENDINSTRUCTION- denotes the end of instruction set
Here's a trivial, but important example to prove the point:
BEGININPUT
BEGINCONTEXT
date: 2021-01-01
url: https://web.site/123
ENDCONTEXT
In a shocking turn of events, blueberries are now green, but will be sticking with the same name.
ENDINPUT
BEGININSTRUCTION
What color are bluberries? Source?
ENDINSTRUCTION
And the expected response:
Blueberries are now green.
Source:
date: 2021-01-01
url: https://web.site/123
References in response
As shown in the example, the dataset includes many examples of including source details in the response, when the question asks for source/citation/references.
Why do this? Well, the R in RAG seems to be the weakest link in the chain. Retrieval accuracy, depending on many factors including the overall dataset size, can be quite low. This accuracy increases when retrieving more documents, but then you have the issue of actually using the retrieved documents in prompts. If you use one prompt per document (or document chunk), you know exactly which document the answer came from, so there's no issue. If, however, you include multiple chunks in a single prompt, it's useful to include the specific reference chunk(s) used to generate the response, rather than naively including references to all of the chunks included in the prompt.
For example, suppose I have two documents:
url: http://foo.bar/1
Strawberries are tasty.
url: http://bar.foo/2
The cat is blue.
If the question being asked is What color is the cat?, I would only expect the 2nd document to be referenced in the response, as the other link is irrelevant.
- Downloads last month
- 7
Model tree for TroyDoesAI/BlackSheep-Llama3.2-3B-Context_Obedient
Base model
TroyDoesAI/BlackSheep-Llama3.2-3B