TS

TSCE – Think Before You Speak (Two-Step Contextual Enrichment for LLMs)

Hacker News

TSCE – Think Before You Speak (Two-Step Contextual Enrichment for LLMs)

Hi HN! 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!

Share card

Actual performance

3points
Did not reach leaderboard

Launch Intel predictions

Analyze your own launch →
Indie HackersFits the IH revenue-focused audience · Missing: supports, reddit linkedin, podcasting
91%91% predicted probability of success on Indie Hackers, based on ML models trained on real launch data.
best fitHighest predicted score across all platforms for this description.
Product HuntOn track for Day 1 leaderboard · Strong signals: model, new, models · Missing: mac, agents, macos
86%86% predicted probability of success on Product Hunt, based on ML models trained on real launch data.
AppSumoStrong fit for a featured deal · Strong signals: calls · Missing: plus, platform, intuitive
61%61% predicted probability of success on AppSumo, based on ML models trained on real launch data.
Hacker NewsStrong engagement from HN community · Strong signals: exist, existing, ide · Missing: https docs, excited, just released
53%53% predicted probability of success on Hacker News, based on ML models trained on real launch data.
nativeThis product was originally launched on this platform.
TrustMRRLess likely to generate early MRR · Missing: mobile apps, ios, personal
45%45% predicted probability of success on TrustMRR, based on ML models trained on real launch data.
Acquire.comPre-revenue stage for this audience · Missing: arr, mrr, revenue
10%10% predicted probability of success on Acquire.com, based on ML models trained on real launch data.
BetaListMay not resonate with beta-testers · Strong signals: chat · Missing: web3, crypto, cryptocurrency
0%0% predicted probability of success on BetaList, based on ML models trained on real launch data.

Incorrect prediction on native model

Similar products

VoiceRix
VoiceRix63%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

speak human. Think Machin

Product Hunt+1
Bt
Bt is approaching 1.0 – The next step in Java torrents41%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Bt is approaching 1.0 – The next step in Java torrents

Hacker News8
So
So you think you can defeat the CAPTCHA55%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

So you think you can defeat the CAPTCHA

Hacker News4
PJ
PJON v10.1 is out! What do you think about it?55%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

PJON v10.1 is out! What do you think about it?

Hacker News4
Bu
Buddha to Bezos - How Greatest Innovators THINK68%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Buddha to Bezos - How Greatest Innovators THINK

Hacker News1
Wa
Warmly - what do you think? 2devs/1week55%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Warmly - what do you think? 2devs/1week

Hacker News2
As
As We May (Yet) Think55%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

As We May (Yet) Think

Hacker News1
Pi
Picnic 4.0 launched. What do you think?44%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Picnic 4.0 launched. What do you think?

Hacker News1
Think SME Pte Ltd
Think SME Pte Ltd47%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Think SME Pte Ltd

Product Hunt
Se
Secretly – Speak Freely46%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Secretly – Speak Freely

Hacker News5