News

Microsoft Improves Natural Language UI for LLMs with Open Source TypeChat

"No more prompt engineering! Types are all you need."

Microsoft announced an open source project called TypeChat to help developers create better natural language UI for working with the large language models (LLMs) in advanced AI-powered applications.

As its name suggests, it leverages the company's TypeScript programming language, which builds on vanilla JavaScript by adding the ability to use types.

The idea behind TypeChat is to provide structured type-safe data -- in a form such as JSON -- that machine language systems can better work with, as opposed to data typically delivered in the form of a casual human conversation. So it's much easier to write code to present the data in a structured way.

Some example apps were published on GitHub to help developers get started creating apps that could use functionality including:

[Click on image for larger view.] Example Apps (source: Microsoft).

For a simplified example, TypeChat can be used in a chatbot app to respond with type-safe data to the user query (or prompt): "Provide 3 suggestions for specific places to go to in Seattle on a rainy day."

Rather than asking the app to work with a natural language response like, "Here are three specific places you can go to in Seattle on a rainy day," it can work with more structured data -- to present in a table for example -- like:

{
  "data": [
    {
      "venue": "Museum of Pop Culture",
      "description": "Explore the fascinating world of popular culture through interactive exhibits, music memorabilia, and multimedia displays at the Museum of Pop Culture."
    },
    {
      "venue": "Seattle Art Museum",
      "description": "Indulge in the diverse collection of artworks from around the world at the Seattle Art Museum, featuring both contemporary and classical pieces."
    },
    {
      "venue": "Pike Place Market",
      "description": "Enjoy the vibrant atmosphere of Pike Place Market, where you can wander through covered stalls offering fresh produce, crafts, and delicious food from local vendors."
    }
  ]
}

However, Microsoft said, examples like the above might help guide structure, but they don't define what an AI should return extensively, or provide anything to be validated against.

TypeScript and its compiler can do those types of things.

Types Are All You Need

"TypeScript has shown that it's well-suited to precisely describe JSON. But what happens when a language model stumbles and makes up a response that doesn't conform to our types?" Microsoft asked in a July 20 blog post.

"Well because these types are valid TypeScript code, we can validate the response against them using the TypeScript compiler itself! In fact, the error feedback from the compiler can even be used to guide repairs. When put together, we can get a robust process for getting well-typed responses that our apps can further massage, validate with a user, etc."

That works to the open source project's goal: "TypeChat was created with the purpose of increasing safety in natural language interfaces."

TypeChat works to go beyond TypeScript compiler capabilities by adding things like:

  • Constructing a prompt to the LLM using types.
  • Validating the LLM response conforms to the schema. If the validation fails, repair the non-conforming output through further language model interaction.
  • Summarizing succinctly (without use of a LLM) the instance and confirm that it aligns with user intent.

A FAQ says: "TypeChat was created with the purpose of increasing safety in natural language interfaces.

We believe TypeChat has three key primary benefits when working with large language models:

  • Accurate: Large language models do a great job matching user intent to scoped types. TypeChat's validation and repair cleans up the rest!
  • Approachable: No more prompt engineering! Types are all you need. You probably have them already lying around.
  • Safety: Types constrain domain and model uncertainty. Repeating back the instance confirms that it aligns with user intent before taking action."

For developers who really want to get started with seeing what TypeChat can do, Microsoft published app examples ranging from Sentiment to Restaurant to Music on GitHub.

Also, Microsoft's TypeChat GitHub.io site provides links to documentation, blog and a readymade npm install typechat command for installing the NuGet package.

About the Author

David Ramel is an editor and writer at Converge 360.

comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube