by DanRosenwasser on 7/20/23, 4:41 PM with 169 comments
by verdverm on 7/20/23, 8:24 PM
Here's the core of the message sent to the LLM: https://github.com/microsoft/TypeChat/blob/main/src/typechat...
You are basically getting a fixed prompt to return structured data with a small amount of automation and vendor lockin. All these LLM libraries are just crappy APIs to the underlying API. It is trivial to write a script that does the same and will be much more flexible as models and user needs evolve.
As an example, think about how you could change the prompt or use python classes instead. How much work would this be using a library like this versus something that lifts the API calls and text templating to the user like: https://github.com/hofstadter-io/hof/blob/_dev/flow/chat/llm...
by andy_xor_andrew on 7/21/23, 3:44 AM
Why all the rigamarole of hoping you get a valid response, adding last-mile validators to detect invalid responses, trying to beg the model to pretty please give me the syntax I'm asking for...
...when you can guarantee a valid JSON syntax by only sampling tokens that are valid? Instead of greedily picking the highest-scoring token every time, you select the highest-scoring token that conforms to the requested format.
This is what Guidance does already, also from Microsoft: https://github.com/microsoft/guidance
But OpenAI apparently does not expose the full scores of all tokens, it only exposes the highest-scoring token. Which is so odd, because if you run models locally, using Guidance is trivial, and you can guarantee your json is correct every time. It's faster to generate, too!
by paxys on 7/20/23, 6:28 PM
Structured requests and responses are 100% the next evolution of LLMs. People are already getting tired of chatbots. Being able to plug in any backend without worrying about text parsing and prompts will be amazing.
by dvt on 7/20/23, 10:38 PM
DeFi/crypto went through this phase 2 years ago. Mark my words, it's going to end up being this weird limbo for a few years where people will slowly realize that AI is a feature, not a product. And that its applicability is limited and that it won't save the world. It won't be able to self-drive cars due to all the edge cases, it won't be able to perform surgeries because it might kill people, etc.
I keep mentioning that even the most useful AI tools (Copilot, etc.) are marginally useful at best. At the very best it saves me a few clicks on Google, but the agents are not "intelligent" in the least. We went through a similar bubble a few years ago with chatbots[1]. These days, no one cares about them. "The metaverse" was much more short-lived, but the same herd mentality applies. "It's the next big thing" until it isn't.
[1] https://venturebeat.com/business/facebook-opens-its-messenge...
by bottlepalm on 7/20/23, 8:06 PM
Also like RSS, if there were some standard URL a websites exposed for AI interaction, using this TypeChat to expose the interfaces, we'd be well on our way here.
by joefreeman on 7/20/23, 6:33 PM
type Item = {
name: string;
...
size?: string;
I'm not really following how this would avoid `name: "grande latte"`?But then the example response:
"size": 16
> This is pretty great!Is it? It's not even returning the type being asked for?
I'm guessing this is more of a typo in the example, because otherwise this seems cool.
by 33a on 7/20/23, 7:00 PM
This is a cute idea and it looks like it should work, but I could see this getting expensive with larger models and input prompts. Probably not a fix for all scenarios.
by garrett_makes on 7/20/23, 9:16 PM
My take on this is, it should be easy for an engineer to spin up a new "bot" with a given LLM. There's a lot of boring work around translating your functions into something ChatGPT understands, then dealing with the response and parsing it back again.
With systems like these you can just focus on writing the actual PHP code, adding a few clear comments, and then the bot can immediately use your code like a tool in whatever task you give it.
Another benefit to things like this, is that it makes it much easier for code to be shared. If someone writes a function, you could pull it into a new bot and immediately use it. It eliminates the layer of "converting this for the LLM to use and understand", which I think is pretty cool and makes building so much quicker!
None of this is perfect yet, but I think this is the direction everything will go so that we can start to leverage each others code better. Think about how we use package managers in coding today, I want a package manager for AI specific tooling. Just install the "get the weather" library, add it to my bot, and now it can get the weather.
by katamaster818 on 7/20/23, 8:30 PM
by parentheses on 7/21/23, 12:09 AM
It not only would allow them to suggest that required fields be completed (avoiding the need for validation [1]) and probably save them GPU time in the end.
There must be a reason and I'm dying to know what it is! :)
Side-note, I was in the process of building this very thing and good ol' Misrocoft just swung in and ate my lunch.. :/
[0] https://github.com/microsoft/guidance
[1] https://github.com/microsoft/TypeChat/blob/main/src/typechat...
by Zaheer on 7/20/23, 8:28 PM
They both seem to aim to solve the problem of getting typed, valid responses back from LLMs
by tlrobinson on 7/21/23, 12:43 AM
const schema = fs.readFileSync(path.join(__dirname, "sentimentSchema.ts"), "utf8");
const translator = typechat.createJsonTranslator<SentimentResponse>(model, schema, "SentimentResponse");
It would have been much nicer if they took this an an opportunity to build generic runtime type introspection into TypeScript.by mahalex on 7/20/23, 8:49 PM
Honestly, this is getting beyond embarrassing. How is this the world we live in?
by gigel82 on 7/21/23, 12:28 AM
But I heard from MS friends that AI is an absolute "need to have". If you're not working on AI, you're not getting (as much) budget. I suspect this is more about ticking the box than producing some complex project. Unfortunately, throughout the company, folks are doing all kinds of weird things to tick the box like writing a "copilot" (with associated azure openai costs) fine-tuned on a handful of documentation articles :(
by huac on 7/21/23, 1:02 AM
Define a struct and tag it with golang's json comments. Then, give it a prompt and ...
type dinnerParty struct {
Topic string `json:"topic" jsonschema:"required" jsonschema_description:"The topic of the conversation"`
RandomWords []string `json:"random_words" jsonschema:"required" jsonschema_description:"Random words to prime the conversation"`
}
completer := openai.NewClient(os.Getenv("OPENAI_API_KEY"))
d := gollum.NewOpenAIDispatcher[dinnerParty]("dinner_party", "Given a topic, return random words", completer, nil)
output, _ := d.Prompt(context.Background(), "Talk to me about dinosaurs")
and you should get a response like expected := dinnerParty{
Topic: "dinosaurs",
RandomWords: []string{"dinosaur", "fossil", "extinct"},
}
by trafnar on 7/20/23, 6:53 PM
by robbie-c on 7/20/23, 10:03 PM
by sandkoan on 7/20/23, 10:19 PM
by _andrei_ on 7/21/23, 3:31 PM
by abhinavkulkarni on 7/21/23, 6:16 AM
Just like many similar methods, this is based on logit biasing, so it may have an impact on quality.
by geysersam on 7/20/23, 11:50 PM
Or are they solving different problems?
It seems jsonformer has some advantages such as only generating tokens for the values and not the structure of the JSON. But this project seems to have more of a closed feedback loop prompt the model to do the right thing.
by waffletower on 7/21/23, 10:25 PM
by rvz on 7/20/23, 6:48 PM
All this is it's just talking to a AI model sitting on someone else's server.
[0] https://github.com/microsoft/TypeChat/blob/main/src/model.ts...
by canadaduane on 7/21/23, 5:02 AM
[1] https://medium.com/@canadaduane/using-zod-to-build-structure...
by jensneuse on 7/20/23, 9:52 PM
by xigoi on 7/21/23, 7:58 AM
by davrous on 7/20/23, 6:19 PM
by waffletower on 7/21/23, 5:36 PM
by nurettin on 7/21/23, 1:31 AM
by vbezhenar on 7/21/23, 10:42 AM
by TillE on 7/21/23, 12:20 AM
by phillipcarter on 7/20/23, 9:00 PM
- Lots of examples / prompt engineering techniques
- MS Guideance
- TypeChat
- OpenAI functions (the model itself is tuned to do this, a key differentiator)
- ...others?
by obiefernandez on 7/20/23, 11:10 PM
by ianzakalwe on 7/20/23, 9:23 PM
by ameyab on 7/20/23, 6:41 PM
by bestcoder69 on 7/20/23, 6:54 PM
by yanis_t on 7/20/23, 7:50 PM
I'm totally happy to be able to receive structured queries, but I'm also not 100% sure TypeScript is the right tool, it seems to be an overkill. I mean obviously you don't need the power of TS with all its enums, generics, etc.
Plus given that it will run multiple queries in loop, it might end up very expensive for it abide by your custom-mage complex type
by nchase on 7/21/23, 12:30 AM
by arc9693 on 7/20/23, 9:05 PM