Instructions to use lamm-mit/BioinspiredMixtral with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lamm-mit/BioinspiredMixtral with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="lamm-mit/BioinspiredMixtral") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("lamm-mit/BioinspiredMixtral") model = AutoModelForCausalLM.from_pretrained("lamm-mit/BioinspiredMixtral") 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]:])) - llama-cpp-python
How to use lamm-mit/BioinspiredMixtral with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="lamm-mit/BioinspiredMixtral", filename="ggml-model-q5_K_M.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use lamm-mit/BioinspiredMixtral with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf lamm-mit/BioinspiredMixtral:Q5_K_M # Run inference directly in the terminal: llama-cli -hf lamm-mit/BioinspiredMixtral:Q5_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf lamm-mit/BioinspiredMixtral:Q5_K_M # Run inference directly in the terminal: llama-cli -hf lamm-mit/BioinspiredMixtral:Q5_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/BioinspiredMixtral:Q5_K_M # Run inference directly in the terminal: ./llama-cli -hf lamm-mit/BioinspiredMixtral:Q5_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/BioinspiredMixtral:Q5_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf lamm-mit/BioinspiredMixtral:Q5_K_M
Use Docker
docker model run hf.co/lamm-mit/BioinspiredMixtral:Q5_K_M
- LM Studio
- Jan
- vLLM
How to use lamm-mit/BioinspiredMixtral with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "lamm-mit/BioinspiredMixtral" # 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/BioinspiredMixtral", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/lamm-mit/BioinspiredMixtral:Q5_K_M
- SGLang
How to use lamm-mit/BioinspiredMixtral 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/BioinspiredMixtral" \ --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/BioinspiredMixtral", "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/BioinspiredMixtral" \ --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/BioinspiredMixtral", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use lamm-mit/BioinspiredMixtral with Ollama:
ollama run hf.co/lamm-mit/BioinspiredMixtral:Q5_K_M
- Unsloth Studio new
How to use lamm-mit/BioinspiredMixtral 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 lamm-mit/BioinspiredMixtral 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 lamm-mit/BioinspiredMixtral to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for lamm-mit/BioinspiredMixtral to start chatting
- Docker Model Runner
How to use lamm-mit/BioinspiredMixtral with Docker Model Runner:
docker model run hf.co/lamm-mit/BioinspiredMixtral:Q5_K_M
- Lemonade
How to use lamm-mit/BioinspiredMixtral with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull lamm-mit/BioinspiredMixtral:Q5_K_M
Run and chat with the model
lemonade run user.BioinspiredMixtral-Q5_K_M
List all available models
lemonade list
Update README.md
Browse files
README.md
CHANGED
|
@@ -48,65 +48,26 @@ llm = Llama.from_pretrained(
|
|
| 48 |
```
|
| 49 |
For inference:
|
| 50 |
```
|
| 51 |
-
def
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
num_beams=1,
|
| 56 |
-
top_k = 50,
|
| 57 |
-
top_p =0.9,repetition_penalty=1.,eos_token_id=2,verbatim=False,
|
| 58 |
-
exponential_decay_length_penalty_fac=None,add_special_tokens =True,
|
| 59 |
-
):
|
| 60 |
-
inputs = tokenizer(text_input, add_special_tokens = add_special_tokens, return_tensors ='pt').to(device)
|
| 61 |
-
|
| 62 |
-
with torch.no_grad():
|
| 63 |
-
|
| 64 |
-
outputs = model.generate (input_ids = inputs["input_ids"],
|
| 65 |
-
attention_mask = inputs["attention_mask"] , # This is usually done automatically by the tokenizer
|
| 66 |
-
max_new_tokens=max_new_tokens,
|
| 67 |
-
temperature=temperature, #value used to modulate the next token probabilities.
|
| 68 |
-
num_beams=num_beams,
|
| 69 |
-
top_k = top_k,
|
| 70 |
-
top_p = top_p,
|
| 71 |
-
num_return_sequences = num_return_sequences,
|
| 72 |
-
eos_token_id=eos_token_id,
|
| 73 |
-
pad_token_id = eos_token_id,
|
| 74 |
-
do_sample =True,#skip_prompt=True,
|
| 75 |
-
repetition_penalty=repetition_penalty,
|
| 76 |
-
)
|
| 77 |
-
|
| 78 |
-
return tokenizer.batch_decode(outputs[:,inputs["input_ids"].shape[1]:].detach().cpu().numpy(), skip_special_tokens=True)
|
| 79 |
-
|
| 80 |
-
def generate_BioMixtral (system_prompt='You a helpful assistant. You are familiar with materials science, especially biological and bioinspired materials. ',
|
| 81 |
-
prompt='What is spider silk in the context of bioinspired materials?',
|
| 82 |
-
repetition_penalty=1.,
|
| 83 |
-
top_p=0.9, top_k=256,
|
| 84 |
-
temperature=0.5, max_tokens=512, verbatim=False, eos_token=None,
|
| 85 |
-
prepend_response='',
|
| 86 |
-
):
|
| 87 |
-
|
| 88 |
-
if eos_token==None:
|
| 89 |
-
eos_token= tokenizer.eos_token_id
|
| 90 |
|
| 91 |
if system_prompt==None:
|
| 92 |
-
messages=[
|
| 93 |
{"role": "user", "content": prompt},
|
| 94 |
]
|
| 95 |
else:
|
| 96 |
-
messages=[
|
| 97 |
-
|
| 98 |
-
|
| 99 |
]
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
top_p=top_p, top_k=top_k,
|
| 107 |
-
temperature=temperature,max_new_tokens=max_tokens, verbatim=verbatim,
|
| 108 |
-
)
|
| 109 |
-
return output_text[0]
|
| 110 |
|
| 111 |
start_time = time.time()
|
| 112 |
result=generate_BioMixtral(system_prompt='You respond accurately.',
|
|
|
|
| 48 |
```
|
| 49 |
For inference:
|
| 50 |
```
|
| 51 |
+
def generate_BioMixtral (system_prompt='You are an expert in biological materials, mechanics and related topics.', prompt="What is spider silk?",
|
| 52 |
+
temperature=0.0,
|
| 53 |
+
max_tokens=10000,
|
| 54 |
+
):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
if system_prompt==None:
|
| 57 |
+
messages=[
|
| 58 |
{"role": "user", "content": prompt},
|
| 59 |
]
|
| 60 |
else:
|
| 61 |
+
messages=[
|
| 62 |
+
{"role": "system", "content": system_prompt},
|
| 63 |
+
{"role": "user", "content": prompt},
|
| 64 |
]
|
| 65 |
+
|
| 66 |
+
result=llm.create_chat_completion(
|
| 67 |
+
messages=messages,
|
| 68 |
+
temperature=temperature,
|
| 69 |
+
max_tokens=max_tokens,
|
| 70 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
start_time = time.time()
|
| 73 |
result=generate_BioMixtral(system_prompt='You respond accurately.',
|