Text Generation
Transformers
Safetensors
multilingual
qwen2
conversational
text-generation-inference
🇪🇺 Region: EU
Instructions to use jinaai/reader-lm-1.5b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jinaai/reader-lm-1.5b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="jinaai/reader-lm-1.5b") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("jinaai/reader-lm-1.5b") model = AutoModelForCausalLM.from_pretrained("jinaai/reader-lm-1.5b") 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]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use jinaai/reader-lm-1.5b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "jinaai/reader-lm-1.5b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "jinaai/reader-lm-1.5b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/jinaai/reader-lm-1.5b
- SGLang
How to use jinaai/reader-lm-1.5b 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 "jinaai/reader-lm-1.5b" \ --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": "jinaai/reader-lm-1.5b", "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 "jinaai/reader-lm-1.5b" \ --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": "jinaai/reader-lm-1.5b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use jinaai/reader-lm-1.5b with Docker Model Runner:
docker model run hf.co/jinaai/reader-lm-1.5b
Hello world example got wrong output
#7
by AIRDGempoll - opened
Hi I am running the hello world example in your doc, but I think the output is sort of wrong.
# in ipython
In [4]: html_content = "<html><body><h1>Hello, world!</h1></body></html>"
...:
...: messages = [{"role": "user", "content": html_content}]
...: input_text=tokenizer.apply_chat_template(messages, tokenize=False)
...:
...: print(input_text)
...:
...: inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
...: outputs = model.generate(inputs, max_new_tokens=1024, temperature=0, do_sample=False, repetition_penalty=1.08)
...:
...: print(tokenizer.decode(outputs[0]))
<|im_start|>system
You are a helpful assistant.<|im_end|>
<|im_start|>user
<html><body><h1>Hello, world!</h1></body></html><|im_end|>
/home/ai/mambaforge/envs/readerlm/lib/python3.12/site-packages/transformers/generation/configuration_utils.py:567: UserWarning: `do_sample` is set to `False`. However, `temperature` is set to `0` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `temperature`.
warnings.warn(
/home/ai/mambaforge/envs/readerlm/lib/python3.12/site-packages/transformers/generation/configuration_utils.py:572: UserWarning: `do_sample` is set to `False`. However, `top_p` is set to `0.8` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `top_p`.
warnings.warn(
/home/ai/mambaforge/envs/readerlm/lib/python3.12/site-packages/transformers/generation/configuration_utils.py:589: UserWarning: `do_sample` is set to `False`. However, `top_k` is set to `20` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `top_k`.
warnings.warn(
<|im_start|>system
You are a helpful assistant.<|im_end|>
<|im_start|>user
<html><body><h1>Hello, world!</h1></body></html><|im_end|>
<|im_start|>assistant
Hello, world!<|im_end|>
I am expecting the output of assistant to be # Hello, world!