logo
Llama-2
repo-copy-icon

copied

Browse Source

Update readme

Signed-off-by: Jael Gu <mengjia.gu@zilliz.com>
main
Jael Gu 1 year ago
parent
commit
6c909ef19d
  1. 6
      README.md
  2. 2
      __init__.py
  3. 3
      llama2.py

6
README.md

@ -59,9 +59,9 @@ p = (
pipe.input('question', 'docs', 'history')
.map(('question', 'docs', 'history'),
'prompt',
ops.prompt.template(temp, ['question', 'context'], sys_message))
ops.prompt.template(temp, ['question', 'context'], system_msg))
.map('prompt', 'answer',
ops.LLM.Llama_2(max_tokens=200))
ops.LLM.Llama_2(temperature=0))
.output('answer')
)
@ -72,7 +72,7 @@ print(q1, ans1)
history.append((q1, ans1))
docs.append('Towhee is a cutting-edge framework designed to streamline the processing of unstructured data through the use of Large Language Model (LLM) based pipeline orchestration.')
ans2 = p(q2, docs, history)
ans2 = p(q2, docs, history).get()[0]
print(q2, ans2)
```

2
__init__.py

@ -1,5 +1,5 @@
from .llama2 import LlamaCpp
def llama_2(*args, **kwargs):
def Llama_2(*args, **kwargs):
return LlamaCpp(*args, **kwargs)

3
llama2.py

@ -39,7 +39,6 @@ class LlamaCpp(PyOperator):
self.model_path = model_name_or_file
assert os.path.isfile(self.model_path), f'Invalid model path: {self.model_path}'
print(111, self.model_path)
self.model = Llama(model_path=self.model_path)
def __call__(self, messages: List[dict]):
@ -52,7 +51,7 @@ class LlamaCpp(PyOperator):
assert isinstance(messages, list), \
'Inputs must be a list of dictionaries with keys from ["system", "question", "answer"].'
prompt = ''
question = messages.pop[-1]
question = messages.pop(-1)
assert len(question) == 1 and 'question' in question.keys()
question = question['question']
for m in messages:

Loading…
Cancel
Save