mjbuehler commited on
Commit
082b385
·
verified ·
1 Parent(s): 484c1ef

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +80 -0
README.md CHANGED
@@ -1,3 +1,83 @@
1
  ---
2
  license: apache-2.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
  ---
4
+ ### BioinspiredZephyr-7B: Large Language Model for the Mechanics of Biological and Bio-Inspired Materials using Mixture-of-Experts
5
+
6
+ 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.
7
+
8
+ 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.
9
+
10
+ The model is based on HuggingFaceH4/zephyr-7b-beta.
11
+
12
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/623ce1c6b66fedf374859fe7/bsqBByauWBZ0Y8PspthR8.png)
13
+
14
+ This model is based on work reported in https://doi.org/10.1002/advs.202306724.
15
+
16
+ This repository includes both, Hugging Face transformers and GGUF files (in different versions, the q5_K_M is recommended).
17
+
18
+ ```
19
+ from llama_cpp import Llama
20
+
21
+ model_path='./BioinspiredZephyr-7B/ggml-model-q5_K_M.gguf'
22
+ chat_format="mistral-instruct"
23
+
24
+ llm = Llama(model_path=model_path,
25
+ n_gpu_layers=-1,verbose= True,
26
+ n_ctx=10000,
27
+ #main_gpu=0,
28
+ chat_format=chat_format,
29
+ #split_mode=llama_cpp.LLAMA_SPLIT_LAYER
30
+ )
31
+ ```
32
+
33
+ Or, download directly from Hugging Face:
34
+
35
+ ```
36
+ from llama_cpp import Llama
37
+
38
+ model_path='lamm-mit/BioinspiredZephyr-7B/ggml-model-q5_K_M.gguf'
39
+ chat_format="mistral-instruct"
40
+
41
+ llm = Llama.from_pretrained(
42
+ repo_id=model_path,
43
+ filename="*q5_K_M.gguf",
44
+ verbose=True,
45
+ n_gpu_layers=-1,
46
+ n_ctx=10000,
47
+ #main_gpu=0,
48
+ chat_format=chat_format,
49
+ )
50
+ ```
51
+ For inference:
52
+ ```
53
+ def generate_BioinspiredZephyr_7B(system_prompt='You are an expert in biological materials, mechanics and related topics.',
54
+ prompt="What is spider silk?",
55
+ temperature=0.0,
56
+ max_tokens=10000,
57
+ ):
58
+ if system_prompt==None:
59
+ messages=[
60
+ {"role": "user", "content": prompt},
61
+ ]
62
+ else:
63
+ messages=[
64
+ {"role": "system", "content": system_prompt},
65
+ {"role": "user", "content": prompt},
66
+ ]
67
+
68
+ result=llm.create_chat_completion(
69
+ messages=messages,
70
+ temperature=temperature,
71
+ max_tokens=max_tokens,
72
+ )
73
+
74
+ start_time = time.time()
75
+ result=generate_BioinspiredZephyr_7B(system_prompt='You respond accurately.',
76
+ prompt="What is graphene? Answer with detail.",
77
+ max_tokens=512, temperature=0.7, )
78
+ print (result)
79
+ deltat=time.time() - start_time
80
+ print("--- %s seconds ---" % deltat)
81
+ toked=tokenizer(res)
82
+ print ("Tokens per second (generation): ", len (toked['input_ids'])/deltat)
83
+ ```