I’d like to share TSCE – a Python library that gives small models the ability to follow instructions with above GPT-4-like precision using a two-step architecture. It’s designed for developers who want reliable, high-quality results without the need for fine-tuning large models.
TL;DR TSCE uses a two-step approach to improve the reliability of language models. This ensures more accurate and coherent outputs, especially for tasks that require rule adherence or detailed instructions.
---
Why You Should Care
* No Fine-Tuning: You don't need to fine-tune models. TSCE works with existing models like GPT-3.5 and GPT-4. * Improved Reliability: By decoupling the thinking process (Phase 1) and the answering process (Phase 2), you get more consistent, on-topic results. * Works with OpenAI and Azure: TSCE works out of the box with both OpenAI and Azure OpenAI APIs, so it’s ready to plug into your existing workflows. * Minimal Overhead: The additional latency is small (~2 API calls), but the payoff is huge in terms of clarity and accuracy.
Example
from tsce import TSCEChat
tsce = TSCEChat(model="gpt-3.5-turbo") prompt = "Provide a brief explanation of the benefits of solar energy and how it impacts the environment. Include an example of a renewable energy source other than solar energy."
reply = tsce(prompt)
print("Answer (Phase 2):", reply.content) # The final response generated after Phase 2 print("Anchor (Phase 1):", reply.anchor) # The structured anchor generated in Phase 1
Output Example:
- *Anchor (Phase 1)*: `solar::harvest~light{clean}—echo::sustain[green]` ###END###`
- *Answer (Phase 2)*: `"Solar energy offers numerous benefits, particularly in terms of environmental impact. Here are some key points:
1. *Clean Energy Source*: Solar energy is a clean and renewable source of power. It generates electricity without emitting greenhouse gases or pollutants, which helps reduce the overall carbon footprint.
2. *Reduction in Fossil Fuel Dependence*: By harnessing solar energy, we can decrease our reliance on fossil fuels, which are finite and contribute significantly to environmental pollution and climate change.
3. *Sustainable and Renewable*: Solar energy is abundant and inexhaustible. As long as the sun shines, we can harness its power, making it a sustainable energy solution for the long term.
4. *Positive Environmental Impact*: Utilizing solar energy reduces air and water pollution, minimizes habitat destruction, and decreases the strain on natural resources. This contributes to a healthier ecosystem and a more balanced natural environment.
*Example of Another Renewable Energy Source*: Wind energy is another excellent example of a renewable energy source. Wind turbines convert the kinetic energy from wind into electrical power. Like solar energy, wind energy is clean, sustainable, and helps reduce greenhouse gas emissions. Wind farms can be established on land or offshore, providing versatile options for generating renewable energy."`
---
Installation
``` pip install tsce ```
Customizing System Prompts
You can easily customize the system instructions for the final pass by passing in a custom *`final_prefix`*:
``` tsce = TSCEChat(final_prefix="You are a helpful assistant, please respond in 3 sentences.") reply = tsce("Explain the concept of recursion.") print(reply.content) ```
---
If you have any questions or want to try it out, feel free to comment here or head over to the repo.
[GitHub Repo](https://github.com/AutomationOptimization/tsce_demo) [GDrive: Read the paper, See the proof](https://tinyurl.com/3xswpzbb)
Looking forward to hearing what you think!
No comments