llmware/slim-topics
SLIM-TOPICS
<!-- Provide a quick summary of what the model is/does. -->
slim-topics is part of the SLIM ("Structured Language Instruction Model") model series, consisting of small, specialized decoder-based models, fine-tuned for function-calling.
slim-sentiment has been fine-tuned for topic analysis function calls, generating output consisting of a python dictionary corresponding to specified keys, e.g.:
{"topics": ["..."]}
SLIM models are designed to generate structured outputs that can be used programmatically as part of a multi-step, multi-model LLM-based automation workflow.
Each slim model has a 'quantized tool' version, e.g., **'slim-topics-tool'**.
Prompt format:
function = "classify" params = "topics" prompt = "<human> " + {text} + "\n" + "<{function}> " + {params} + "</{function}>" + "\n<bot>:"
<details> <summary>Transformers Script </summary>
model = AutoModelForCausalLM.frompretrained("llmware/slim-topics") tokenizer = AutoTokenizer.frompretrained("llmware/slim-topics")
function = "classify" params = "topic"
text = "The stock market declined yesterday as investors worried increasingly about the slowing economy."
prompt = "<human>: " + text + "\n" + f"<{function}> {params} </{function}>\n<bot>:"
inputs = tokenizer(prompt, returntensors="pt") startofinput = len(inputs.inputids[0])
outputs = model.generate( inputs.inputids.to('cpu'), eostokenid=tokenizer.eostokenid, padtokenid=tokenizer.eostokenid, dosample=True, temperature=0.3, maxnewtokens=100 )
outputonly = tokenizer.decode(outputs[0][startofinput:], skipspecial_tokens=True)
print("output only: ", output_only)
# here's the fun part try: outputonly = ast.literaleval(llmstringoutput) print("success - converted to python dictionary automatically") except: print("fail - could not convert to python dictionary automatically - ", llmstringoutput)
</details>
<details>
<summary>Using as Function Call in LLMWare</summary>
from llmware.models import ModelCatalog slimmodel = ModelCatalog().loadmodel("llmware/slim-topics") response = slimmodel.functioncall(text,params=["topics"], function="classify")
print("llmware - llm_response: ", response)
</details>
Model Card Contact
Darren Oberst & llmware team
