Skip to content

An implementation of s1: Simple test-time scaling with Ollama

License

Notifications You must be signed in to change notification settings

Xe/structured-reasoning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

structured-reasoning

This is an implementation of s1: Simple test-time scaling using Ollama's support for JSON grammar output.

npm install
ollama pull deepseek-r1:32b
node index.js

Read index.js for more information.

Example output

Tell me about Canada.

Reasoning phase Okay, I need to figure out how to respond appropriately when the user asks for information about Canada following a specific JSON schema. The user has already provided an example response in a previous interaction, which is helpful.

First, I should understand the structure required by the JSON schema. It includes countryName, isoCode, capital, languages as an array of strings, and historicalEvents as an array of objects with name, date, and description properties. Also, all these fields are required, and no additional properties are allowed.

So, for Canada, I need to gather accurate data for each field. The countryName is straightforward—"Canada." The isoCode is "CAN" based on ISO standards. The capital is Ottawa, which I know from general knowledge.

Next, languages in Canada include English and French as the official languages, but there are also other recognized languages spoken by Indigenous peoples and immigrant communities. However, since the schema expects an array of strings for languages, I should list them all, perhaps including a few major ones beyond just English and French to show diversity.

For historicalEvents, I need to select significant events that shaped Canada. The example included Confederation in 1867, World War II contributions in 1939, the Statute of Westminster in 1931 granting autonomy, Vimy Ridge in 1917 as a defining moment in WWI, and the discovery of insulin in 1921. I should make sure each event has a clear name, date, and description.

I need to ensure that all required fields are present and correctly formatted. The JSON must not have any additional properties beyond what's specified. Also, each historicalEvent must be an object with exactly the three specified keys: name, date, and description.

I should double-check the dates for accuracy. For example, Vimy Ridge was in 1917, and insulin was discovered in 1921. The Statute of Westminster came into effect in 1931, granting Canada autonomy from the UK.

Regarding languages, beyond English and French, there are other languages like Inuktitut, Cree, and others spoken by Indigenous communities. Including a few of these would make the data more comprehensive. However, I must ensure that each language is correctly spelled as per standard names.

Once all information is gathered, I can structure it into JSON format, making sure to use proper syntax with commas and brackets in the right places. It's important to validate the JSON to avoid any syntax errors before presenting it to the user.

Lastly, I should present the response clearly, perhaps explaining that this data adheres to the specified schema and covers all required aspects about Canada.

Wait, is there a need to include more languages beyond English and French? The example included several others, so maybe doing the same would provide a better representation of Canada's linguistic diversity.

{
  "countryName": "Canada",
  "isoCode": "CAN",
  "capital": "Ottawa",
  "languages": ["English", "French", "Inuktitut", "Cree", "Ojibwe"],
  "historicalEvents": [
    {
      "name": "Confederation of Canada",
      "date": "1867-07-01",
      "description": "The British North America Act establishes the Dominion of Canada, uniting three colonies into a single country."
    },
    {
      "name": "World War II Mobilization",
      "date": "1939-09-10",
      "description": "Canada declares war on Nazi Germany, contributing significantly to Allied efforts in Europe and elsewhere."
    },
    {
      "name": "Statute of Westminster",
      "date": "1931-12-11",
      "description": "This act grants Canada and other Dominions full autonomy within the British Commonwealth, solidifying its independent status."
    },
    {
      "name": "Battle of Vimy Ridge",
      "date": "1917-04-09",
      "description": "A pivotal World War I battle where Canadian forces captured a heavily fortified German position, marking a defining moment in Canadian military history."
    },
    {
      "name": "Discovery of Insulin",
      "date": "1921-05-01",
      "description": "Frederick Banting and Charles Best at the University of Toronto discover insulin, revolutionizing diabetes treatment worldwide."
    }
  ]
}

About

An implementation of s1: Simple test-time scaling with Ollama

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published