PSanni commited on
Commit
cd4c7dc
1 Parent(s): 5623e50

information

Browse files
Files changed (1) hide show
  1. README.md +68 -1
README.md CHANGED
@@ -5,4 +5,71 @@ datasets:
5
  metrics:
6
  - accuracy
7
  pipeline_tag: text-generation
8
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  metrics:
6
  - accuracy
7
  pipeline_tag: text-generation
8
+ ---
9
+
10
+ ## Summary
11
+
12
+ `Deer-3b`, an instruction-following large language model trained on the open source dataset
13
+ that is licensed for commercial use. Based on `Bloom-3b`, Deer is trained on ~15k instruction/response fine tuning records
14
+ [`databricks-dolly-15k`](https://github.com/databrickslabs/dolly/tree/master/data) generated
15
+ by Databricks.
16
+
17
+ Deer will also be available in larger models size.
18
+
19
+ ## Model Overview
20
+ `deer-3b` is a 3 billion parameter causal language model created that is derived from
21
+ [Blooms’s] 3B model and fine-tuned
22
+ on a [~15K record instruction corpus](https://github.com/databrickslabs/dolly/tree/master/data) generated by Databricks.
23
+
24
+ ## Usage
25
+
26
+ To use the model with the `transformers` library on a machine with GPUs.
27
+
28
+ ```python
29
+ import torch
30
+ from transformers import pipeline
31
+ generate_text = pipeline(model="PSanni/Deer-3b", torch_dtype=torch.bfloat16, trust_remote_code=True, device_map="auto")
32
+ ```
33
+
34
+ You can then use the pipeline to answer instructions:
35
+
36
+ ```python
37
+ res = generate_text("Explain to me the difference between nuclear fission and fusion.")
38
+ print(res[0]["generated_text"])
39
+ ```
40
+
41
+ ### LangChain Usage
42
+
43
+ To use the pipeline with LangChain, you must set `return_full_text=True`, as LangChain expects the full text to be returned
44
+ and the default for the pipeline is to only return the new text.
45
+
46
+ ```python
47
+ import torch
48
+ from transformers import pipeline
49
+ generate_text = pipeline(model="PSanni/Deer-3b", torch_dtype=torch.bfloat16,
50
+ trust_remote_code=True, device_map="auto", return_full_text=True)
51
+ ```
52
+
53
+ You can create a prompt that either has only an instruction or has an instruction with context:
54
+
55
+ ```python
56
+ from langchain import PromptTemplate, LLMChain
57
+ from langchain.llms import HuggingFacePipeline
58
+ # template for an instrution with no input
59
+ prompt = PromptTemplate(
60
+ input_variables=["instruction"],
61
+ template="{instruction}")
62
+ # template for an instruction with input
63
+ prompt_with_context = PromptTemplate(
64
+ input_variables=["instruction", "context"],
65
+ template="{instruction}\n\nInput:\n{context}")
66
+ hf_pipeline = HuggingFacePipeline(pipeline=generate_text)
67
+ llm_chain = LLMChain(llm=hf_pipeline, prompt=prompt)
68
+ llm_context_chain = LLMChain(llm=hf_pipeline, prompt=prompt_with_context)
69
+ ```
70
+
71
+ Example predicting using a simple instruction:
72
+
73
+ ```python
74
+ print(llm_chain.predict(instruction="Give me list of morning exercises.").lstrip())
75
+ ```