Instructions to use RedHenLabs/news-reporter-3b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use RedHenLabs/news-reporter-3b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="RedHenLabs/news-reporter-3b", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("RedHenLabs/news-reporter-3b", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("RedHenLabs/news-reporter-3b", trust_remote_code=True) 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 RedHenLabs/news-reporter-3b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "RedHenLabs/news-reporter-3b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "RedHenLabs/news-reporter-3b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/RedHenLabs/news-reporter-3b
- SGLang
How to use RedHenLabs/news-reporter-3b 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 "RedHenLabs/news-reporter-3b" \ --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": "RedHenLabs/news-reporter-3b", "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 "RedHenLabs/news-reporter-3b" \ --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": "RedHenLabs/news-reporter-3b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use RedHenLabs/news-reporter-3b with Docker Model Runner:
docker model run hf.co/RedHenLabs/news-reporter-3b
News reporter 3B LLM
Model Description
News Reporter 3B LLM is based on Phi-3 Mini-4K Instruct a dense decoder-only Transformer model designed to generate high-quality text based on user prompts. With 3.8 billion parameters, the model is fine-tuned using Supervised Fine-Tuning (SFT) to align with human preferences and question answer pairs.
Base Model
We evaluated multiple off-the-shelf models, including Gemma-7B, Gemma-2B, Llama-3-8B, and Phi-3-mini-4K, and found that the Phi-3-mini-4K model performed best overall for our evaluation set. This model excels in multilingual query understanding and response generation, thanks to its 3.8 billion parameters and a 4096 context window length. Trained with over 3.3 trillion tokens, Phi-3-mini-4K stands out for its ability to be quantized to 4 bits, reducing its memory footprint to around 1.8 GB. It processes 8 to 12 tokens per second on a single T4 GPU, requiring just 3-4 GB of VRAM for inference.
Key Features:
- Parameter Count: 3.8 billion.
- Architecture: Dense decoder-only Transformer.
- Context Length: Supports up to 4,000 tokens.
- Training Data: 43.5K+ question and answer pairs curated from different News channel.
Inference
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline,set_seed
model_name = "RedHenLabs/news-reporter-3b"
tokenizer = AutoTokenizer.from_pretrained(model_name,trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_name, trust_remote_code=True, torch_dtype="auto", device_map="cuda")
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
def test_inference(prompt):
prefix = "Generate a concise and accurate news summary based on the following question.\n Input:"
prompt = pipe.tokenizer.apply_chat_template([{"role": "user", "content": prefix+prompt}], tokenize=False, add_generation_prompt=True)
outputs = pipe(prompt, max_new_tokens=512, do_sample=True, num_beams=1, temperature=0.1, top_k=50, top_p=0.95,
max_time= 180)
return outputs[0]['generated_text'][len(prompt):].strip()
res = test_inference(" What is the status of the evacuations and the condition of those injured?")
print(res)
Model Benchmark
| (0 Shot) | News-reporter-3b | Phi-3-mini-4k | Gemma-7b-it | Llama-2-7B | Mistral-7B-Instruct-v0.2 |
|---|---|---|---|---|---|
| MMLU | 69.49 | 69.90 | 64.3 | 45.3 | 59.02 |
| ARC_C | 56.40 | 56.14 | 53.2 | 45.9 | 55.89 |
| Winogrande | 74.19 | 73.24 | 68.03 | 69.5 | 73.72 |
| Truthfulqa | 50.43 | 66.46 | 44.18 | 57.4 | 53.00 |
Citation
@misc {lucifertrj,
author = { {Tarun Jain} },
title = { News Reporter 3B by Red Hen Lab part of Google Summer of Code 2024},
year = 2024,
url = { https://huggingface.co/RedHenLabs/news-reporter-3b },
publisher = { Hugging Face }
}
arxiv.org/abs/2410.07520
- Downloads last month
- 18