Update README.md
Browse files
README.md
CHANGED
|
@@ -8,20 +8,20 @@ license: apache-2.0
|
|
| 8 |
|
| 9 |
**slim-sentiment** is part of the SLIM ("Structured Language Instruction Model") model series, providing a set of small, specialized decoder-based LLMs, fine-tuned for function-calling.
|
| 10 |
|
| 11 |
-
slim-sentiment has been fine-tuned for **sentiment analysis** function calls, generating output consisting of
|
| 12 |
|
| 13 |
Each slim model has a corresponding 'tool' in a separate repository, e.g.,
|
| 14 |
|
| 15 |
[**'slim-sentiment-tool'**](https://huggingface.co/llmware/slim-sentiment-tool), which a 4-bit quantized gguf version of the model that is intended to be used for inference.
|
| 16 |
|
| 17 |
-
Inference speed and loading time is much faster with the 'tool' versions of the model.
|
| 18 |
|
| 19 |
### Model Description
|
| 20 |
|
| 21 |
<!-- Provide a longer summary of what this model is. -->
|
| 22 |
|
| 23 |
- **Developed by:** llmware
|
| 24 |
-
- **Model type:**
|
| 25 |
- **Language(s) (NLP):** English
|
| 26 |
- **License:** Apache 2.0
|
| 27 |
- **Finetuned from model:** Tiny Llama 1B
|
|
@@ -30,24 +30,49 @@ Inference speed and loading time is much faster with the 'tool' versions of the
|
|
| 30 |
|
| 31 |
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 32 |
|
| 33 |
-
The intended use of SLIM models is to re-imagine traditional 'hard-coded' classifiers through the use of function calls.
|
| 34 |
|
| 35 |
Example:
|
| 36 |
|
| 37 |
text = "The stock market declined yesterday as investors worried increasingly about the slowing economy."
|
| 38 |
|
| 39 |
-
model generation -
|
| 40 |
|
|
|
|
| 41 |
keys = "sentiment"
|
| 42 |
|
| 43 |
All of the SLIM models use a novel prompt instruction structured as follows:
|
| 44 |
|
| 45 |
-
"<human> " + text + "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
|
|
|
|
|
|
|
|
|
| 48 |
## How to Get Started with the Model
|
| 49 |
|
| 50 |
-
The fastest way to get started with
|
| 51 |
|
| 52 |
import ast
|
| 53 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
@@ -74,20 +99,6 @@ The fastest way to get started with BLING is through direct import in transforme
|
|
| 74 |
print("llm_response - ", output_only)
|
| 75 |
|
| 76 |
# where it gets interesting
|
| 77 |
-
try:
|
| 78 |
-
# convert llm response output from string to json
|
| 79 |
-
output_only = ast.literal_eval(output_only)
|
| 80 |
-
print("converted to json automatically")
|
| 81 |
-
|
| 82 |
-
# look for the key passed in the prompt as a dictionary entry
|
| 83 |
-
if keys in output_only:
|
| 84 |
-
if "negative" in output_only[keys]:
|
| 85 |
-
print("sentiment appears negative - need to handle ...")
|
| 86 |
-
else:
|
| 87 |
-
print("response does not appear to include the designated key - will need to try again.")
|
| 88 |
-
|
| 89 |
-
except:
|
| 90 |
-
print("could not convert to json automatically - ", output_only)
|
| 91 |
|
| 92 |
|
| 93 |
## Using as Function Call in LLMWare
|
|
|
|
| 8 |
|
| 9 |
**slim-sentiment** is part of the SLIM ("Structured Language Instruction Model") model series, providing a set of small, specialized decoder-based LLMs, fine-tuned for function-calling.
|
| 10 |
|
| 11 |
+
slim-sentiment has been fine-tuned for **sentiment analysis** function calls, generating output consisting of a python dictionary corresponding to specified keys.
|
| 12 |
|
| 13 |
Each slim model has a corresponding 'tool' in a separate repository, e.g.,
|
| 14 |
|
| 15 |
[**'slim-sentiment-tool'**](https://huggingface.co/llmware/slim-sentiment-tool), which a 4-bit quantized gguf version of the model that is intended to be used for inference.
|
| 16 |
|
| 17 |
+
Inference speed and loading time is much faster with the 'tool' versions of the model, and multiple tools can be deployed concurrently and run on a local CPU-based laptop or server.
|
| 18 |
|
| 19 |
### Model Description
|
| 20 |
|
| 21 |
<!-- Provide a longer summary of what this model is. -->
|
| 22 |
|
| 23 |
- **Developed by:** llmware
|
| 24 |
+
- **Model type:** SLIM - small, specialized LLM
|
| 25 |
- **Language(s) (NLP):** English
|
| 26 |
- **License:** Apache 2.0
|
| 27 |
- **Finetuned from model:** Tiny Llama 1B
|
|
|
|
| 30 |
|
| 31 |
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 32 |
|
| 33 |
+
The intended use of SLIM models is to re-imagine traditional 'hard-coded' classifiers through the use of function calls, and to provide a natural language flexible tool that can be used as decision gates and processing steps in a complex LLM-based automation workflow.
|
| 34 |
|
| 35 |
Example:
|
| 36 |
|
| 37 |
text = "The stock market declined yesterday as investors worried increasingly about the slowing economy."
|
| 38 |
|
| 39 |
+
model generation output- {"sentiment": ["negative"]}
|
| 40 |
|
| 41 |
+
function = "classify"
|
| 42 |
keys = "sentiment"
|
| 43 |
|
| 44 |
All of the SLIM models use a novel prompt instruction structured as follows:
|
| 45 |
|
| 46 |
+
"<human> " + {text} + "\n" +
|
| 47 |
+
|
| 48 |
+
"<{function}> " + {keys} + "</{function}>" +
|
| 49 |
+
|
| 50 |
+
"/n<bot>:"
|
| 51 |
+
|
| 52 |
+
For example, in this case, the prompt would be as follows:
|
| 53 |
+
|
| 54 |
+
"<human>" + "The stock market declined yesterday ..." + "\n" + "<classify> sentiment </classify>" + "\n<bot>:"
|
| 55 |
+
|
| 56 |
+
The model generation output will be a string in the form of a well-formed python dictionary, which can be converted as follows:
|
| 57 |
+
|
| 58 |
+
try:
|
| 59 |
+
# convert llm response output from string to json
|
| 60 |
+
output_only = ast.literal_eval(output_only)
|
| 61 |
+
print("converted to python dictionary automatically")
|
| 62 |
|
| 63 |
+
# look for the key passed in the prompt as a dictionary entry
|
| 64 |
+
if keys in output_only:
|
| 65 |
+
if "negative" in output_only[keys]:
|
| 66 |
+
print("sentiment appears negative - need to handle ...")
|
| 67 |
+
else:
|
| 68 |
+
print("response does not appear to include the designated key - will need to try again.")
|
| 69 |
|
| 70 |
+
except:
|
| 71 |
+
print("could not convert to python dictionary automatically - ", output_only)
|
| 72 |
+
|
| 73 |
## How to Get Started with the Model
|
| 74 |
|
| 75 |
+
The fastest way to get started with SLIM is through direct import in transformers:
|
| 76 |
|
| 77 |
import ast
|
| 78 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
| 99 |
print("llm_response - ", output_only)
|
| 100 |
|
| 101 |
# where it gets interesting
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
|
| 104 |
## Using as Function Call in LLMWare
|