-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
Copy pathusing_slim_summary.py
45 lines (31 loc) · 2.02 KB
/
using_slim_summary.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
""" This example illustrates how to use slim-summary models to easily create summaries generated as a list of
summary points for easy integration into multi-step workflows. There are several slim-summary function-calling
models available in different sizes and based on leading underlying base models. """
from llmware.models import ModelCatalog
# three slim-summary function calling models available
slim_summary_models = ["slim-summary-tool", # original - stablelm-3b
"slim-summary-tiny-tool", # small - tiny-llama (1.1b)
"slim-summary-phi-3-gguf" # phi-3 - phi-3 (3.8b)
]
# load the model and set the sampling and output parameters
model = ModelCatalog().load_model("slim-summary-tool",
sample=False,
temperature=0.0,
max_output=200)
# get the test data set packaged with the model
test_script = ModelCatalog().get_test_script("slim-summary-tool")
# iterate through the samples
for i, sample in enumerate(test_script):
# invoke function call on the model, passing the context passage and the 'summarize' function
# the parameter can be a generic phrase, e.g., 'key points' or 'brief description' or 'summary'
# if the material has a lot of numeric data points, try the parameter 'data points' or 'financial data points'
# if you are looking for a single line of output, try 'brief description'
# the number in ( ) is optional - but is intended to guide the model to provide with a list with the requested
# number of elements
response = model.function_call(sample["context"], function="summarize", params=["data points (5)"])
# display the response
print("\nresponse: ", response)
# check how effectively the model mapped the output to the requested number of points
r = response["llm_response"]
for j, entries in enumerate(r):
print("summary points: ", j, entries)