BioinspiredZephyr-7B: Large Language Model for the Mechanics of Biological and Bio-Inspired Materials
To accelerate discovery and guide insights, we report an open-source autoregressive transformer large language model (LLM), trained on expert knowledge in the biological materials field, especially focused on mechanics and structural properties.
The model is finetuned with a corpus of over a thousand peer-reviewed articles in the field of structural biological and bio-inspired materials and can be prompted to recall information, assist with research tasks, and function as an engine for creativity.
The model is based on HuggingFaceH4/zephyr-7b-beta.
This repository includes both, Hugging Face transformers and GGUF files (in different versions, the q5_K_M is recommended).
Hugging Face transformers files: Loading and inference
from transformers import AutoModelForCausalLM, AutoTokenizer
from accelerate import infer_auto_device_map
model = AutoModelForCausalLM.from_pretrained(
model_name,
trust_remote_code=True,
device_map="auto", #device_map="cuda:0",
torch_dtype= torch.bfloat16,
# use_flash_attention_2=True,
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
Chat template
messages = [
{"role": "system", "content": "You are a friendly materials scientist."},
{"role": "user", "content": "What is the strongest spider silk material?"},
{"role": "assistant", "content": "Sample response."},
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
'<|system|>\nYou are a friendly materials scientist.\n<|user|>\nWhat is the strongest spider silk material?\n<|assistant|>\nSample response.\n<|assistant|>\n'
device='cuda'
def generate_response (text_input="Biological materials offer amazing possibilities, such as",
num_return_sequences=1,
temperature=1.,
max_new_tokens=127,
num_beams=1,
top_k = 50,
top_p =0.9,repetition_penalty=1.,eos_token_id=2,verbatim=False,
exponential_decay_length_penalty_fac=None,
):
inputs = tokenizer.encode(text_input, add_special_tokens =False, return_tensors ='pt')
if verbatim:
print ("Length of input, tokenized: ", inputs.shape, inputs)
with torch.no_grad():
outputs = model.generate(input_ids=inputs.to(device),
max_new_tokens=max_new_tokens,
temperature=temperature, #value used to modulate the next token probabilities.
num_beams=num_beams,
top_k = top_k,
top_p =top_p,
num_return_sequences = num_return_sequences, eos_token_id=eos_token_id,
do_sample =True,
repetition_penalty=repetition_penalty,
)
return tokenizer.batch_decode(outputs[:,inputs.shape[1]:].detach().cpu().numpy(), skip_special_tokens=True)
Then:
messages = [
{"role": "system", "content": "You are a friendly materials scientist."},
{"role": "user", "content": "What is the strongest spider silk material?"},
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
output_text=generate_response (text_input=prompt, eos_token_id=eos_token,
num_return_sequences=1, repetition_penalty=1.,
top_p=0.9, top_k=512,
temperature=0.1,max_new_tokens=512, verbatim=False,
)
print (output_text)
BioinspiredZephyr-7B huggingface.co is an AI model on huggingface.co that provides BioinspiredZephyr-7B's model effect (), which can be used instantly with this lamm-mit BioinspiredZephyr-7B model. huggingface.co supports a free trial of the BioinspiredZephyr-7B model, and also provides paid use of the BioinspiredZephyr-7B. Support call BioinspiredZephyr-7B model through api, including Node.js, Python, http.
BioinspiredZephyr-7B huggingface.co is an online trial and call api platform, which integrates BioinspiredZephyr-7B's modeling effects, including api services, and provides a free online trial of BioinspiredZephyr-7B, you can try BioinspiredZephyr-7B online for free by clicking the link below.
lamm-mit BioinspiredZephyr-7B online free url in huggingface.co:
BioinspiredZephyr-7B is an open source model from GitHub that offers a free installation service, and any user can find BioinspiredZephyr-7B on GitHub to install. At the same time, huggingface.co provides the effect of BioinspiredZephyr-7B install, users can directly use BioinspiredZephyr-7B installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
BioinspiredZephyr-7B install url in huggingface.co: