Instructions to use openlm-research/open_llama_13b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use openlm-research/open_llama_13b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="openlm-research/open_llama_13b")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("openlm-research/open_llama_13b") model = AutoModelForCausalLM.from_pretrained("openlm-research/open_llama_13b") - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use openlm-research/open_llama_13b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "openlm-research/open_llama_13b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "openlm-research/open_llama_13b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/openlm-research/open_llama_13b
- SGLang
How to use openlm-research/open_llama_13b 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 "openlm-research/open_llama_13b" \ --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": "openlm-research/open_llama_13b", "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 "openlm-research/open_llama_13b" \ --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": "openlm-research/open_llama_13b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use openlm-research/open_llama_13b with Docker Model Runner:
docker model run hf.co/openlm-research/open_llama_13b
question answering using llama
Hi,
Can someone tell me how to run question answering model using LLama? I'm trying to build QuestionAnswering model , when I run its not giving correct answer even though passing context along it.
from langchain import PromptTemplate, HugginFacePipeline, LLMChain
from transformers import pipeline
import torch
template = """Read this article and answer the below question {context}\n {question} \n if you don;t know the answer please say "I don't know" don't make up on your own."""
prompt = PromptTemplate(template=template, input_variables=["context", "question"])
model_name = "openlm-research/llama-7b-hf"
hf_pipe = HugginFacePipeline(pipeline=pipeline(model=model_name, device='cuda:0', torch_dtype=torch.float16, max_new_tokens=512))
llm_chain = LLMChain(prompt=prompt, llm=hf_pipe)
torch.cuda.empty.cache()
result = llm_chain.run(context=input_context, question=user_question)
I'm using the above script but it is not giving correct answer even though answer present in the context, can someone help me here?
You're trying this with an untrained model, which is effectively a fancy auto-complete. The answer being present in the context doesn't matter if it doesn't know (e.g. its attention mechanism hasn't been trained) to look for it there!
Try fine-tuning the model first:
https://huggingface.co/docs/transformers/tasks/question_answering
https://colab.research.google.com/drive/1VoYNfYDKcKRQRor98Zbf2-9VQTtGJ24k?usp=sharing#scrollTo=XIyP_0r6zuVc