Instructions to use lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha") model = AutoModelForCausalLM.from_pretrained("lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha", device_map="auto") 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 Settings
- llama.cpp
How to use lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha:Q4_K_M # Run inference directly in the terminal: llama cli -hf lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha:Q4_K_M # Run inference directly in the terminal: llama cli -hf lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha:Q4_K_M
Use Docker
docker model run hf.co/lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha:Q4_K_M
- SGLang
How to use lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha 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 "lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha" \ --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": "lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha", "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 "lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha" \ --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": "lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha with Ollama:
ollama run hf.co/lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha:Q4_K_M
- Unsloth Desktop
- Docker Model Runner
How to use lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha with Docker Model Runner:
docker model run hf.co/lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha:Q4_K_M
- Lemonade
How to use lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha:Q4_K_M
Run and chat with the model
lemonade run user.Bioinspired-Llama-3-1-70B-128k-alpha-Q4_K_M
List all available models
lemonade list
- Atomic Chat
Inference example
model_name='lamm-mit/Bioinspired-Llama-3-1-70B-128k-alpha'
model = AutoModelForCausalLM.from_pretrained(
model_name,
trust_remote_code=True,
device_map="auto",
torch_dtype =torch.bfloat16,
attn_implementation="flash_attention_2"
)
model.config.use_cache = True
tokenizer = AutoTokenizer.from_pretrained(model_name)
Check https://huggingface.co/lamm-mit/BioinspiredLlama-3-1-8B-128k-dominant-protein-SS-structure for further examples use of the model for protein structural features prediction, including a fine-tuning script.
Function to interact with the model
def generate_response (text_input="What is spider silk?",
system_prompt='',
num_return_sequences=1,
temperature=1., #the higher the temperature, the more creative the model becomes
max_new_tokens=127,device='cuda',
add_special_tokens = False, #since tokenizer.apply_chat_template adds <|begin_of_text|> template already, set to False
num_beams=1,eos_token_id= [
128001,
128008,
128009
], verbatim=False,
top_k = 50,
top_p = 0.9,
repetition_penalty=1.1,
messages=[],
):
if messages==[]: #start new messages dictionary
if system_prompt != '': #include system prompt if provided
messages.extend ([ {"role": "system", "content": system_prompt}, ])
messages.extend ( [ {"role": "user", "content": text_input}, ])
else: #if messages provided, will extend (make sure to add previous response as assistant message)
messages.append ({"role": "user", "content": text_input})
text_input = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
inputs = tokenizer([text_input], add_special_tokens = add_special_tokens, return_tensors ='pt' ).to(device)
if verbatim:
print (inputs)
with torch.no_grad():
outputs = model.generate(**inputs,
max_new_tokens=max_new_tokens,
temperature=temperature,
num_beams=num_beams,
top_k = top_k,eos_token_id=eos_token_id,
top_p =top_p,
num_return_sequences = num_return_sequences,
do_sample =True, repetition_penalty=repetition_penalty,
)
outputs=outputs[:, inputs["input_ids"].shape[1]:]
return tokenizer.batch_decode(outputs.detach().cpu().numpy(), skip_special_tokens=True), messages
Usage:
res,_= generate_response (text_input = "What is collagen?", system_prompt = 'You are a materials scientist.',
num_return_sequences=1,
temperature=1., #the higher the temperature, the more creative the model becomes
max_new_tokens=127,
num_beams=1,
top_k = 50, top_p =0.9, repetition_penalty=1.1,
)
print (res[0])
To realize multi-turn interactions, see this example:
res, messages = generate_response (text_input="What is spider silk?", messages=[])
messages.append ({"role": "assistant", "content": res[0]}, ) #append result to messages dict
print (res)
res, messages = generate_response (text_input="Explain this result in detail.", messages=messages)
messages.append ({"role": "assistant", "content": res[0]}, ) #append result to messages dict
print (res)
res, messages = generate_response (text_input="Provide this in JSON format.", messages=messages)
messages.append ({"role": "assistant", "content": res[0]}) #append result to messages dict
print (res)
- Downloads last month
- 137