laitimes

Microsoft open source TypeChat library, give large language models a different hint, one line of code installation

author:Heart of the Machine Pro

Machine Heart report

Editor: Chen Ping

With TypeChat, it's easy to get well-typed structured data.

Over the past few months, we've seen a wave of discussion around the latest wave of big language models. Many people communicate with the big model in a conversational way, which is also the most direct way.

But there's a problem with this approach: how best to integrate these models into existing application interfaces remains a big problem.

In other words, how do we leverage AI to translate a user's request into something that the application is capable of processing? And how do we ensure that our apps are secure and are being done with work that developers and users can trust?

To solve this problem, Microsoft has open-sourced an experimental library called TypeChat, which makes it easy to obtain well-typed structured data, which bridges the gap between natural language and application schemas and APIs.

Microsoft open source TypeChat library, give large language models a different hint, one line of code installation

Project address: https://github.com/Microsoft/TypeChat

Currently, TypeChat already has some very basic integrations with the OpenAI API and Azure OpenAI service.

"With TypeChat, AI can output accurate JSON to integrate with human-developed systems," the netizen said.

Microsoft open source TypeChat library, give large language models a different hint, one line of code installation

"TypeChat replaces prompt projects with schema projects: instead of writing unstructured natural language prompts to describe the format of the desired output, you write TS type definitions."

Microsoft open source TypeChat library, give large language models a different hint, one line of code installation

Some netizens said that TypeChat is a big step into the future.

Microsoft open source TypeChat library, give large language models a different hint, one line of code installation

Introduction to TypeChat

It only takes one line of code to get TypeChat up and running:

Microsoft open source TypeChat library, give large language models a different hint, one line of code installation

As for why the TypeChat library is built, Microsoft said that people can currently communicate with LLM, in which language needs to be parsed, however, the language of human input and the language understood by LLM are very different in structure, and it is difficult for typical software to reconstruct language from the original text.

TypeChat helps LLM respond in JSON with a very reasonable response: for example, a user asks for the phrase "Can I ask for a blueberry muffin and a premium latte?" Converted to JSON format, TypeChat response result is as follows:

Microsoft open source TypeChat library, give large language models a different hint, one line of code installation

Microsoft says they've been using TypeScript types in prompts, and arguably, given a prompt and TS type, the chatbot will use those types to construct a new prompt:

Microsoft open source TypeChat library, give large language models a different hint, one line of code installation
Microsoft open source TypeChat library, give large language models a different hint, one line of code installation

Below is the basic code to connect TypeChat to LLM and determine whether the sentence is negative, neutral, or affirmative.

TypeChat can be used in a number of different ways. The way Microsoft is currently discussing is mainly to use data patterns to translate user intent into structured responses; However, TypeChat can also use API patterns to build basic programs.

If you want to experience it, you can try it.

Reference Links:

https://microsoft.github.io/TypeChat/blog/introducing-typechat/

Read on