Live data from Hacker News

Show HN: Fructose – LLM calls as strongly typed functions

github.com

91–100 of 105 posts

Re: Show HN: Fructose – LLM calls as strongly typed functions

#91
post #78

Earlier quoted context omitted.

Wait, someone made a similar comment as this elsewhere in the thread. So why don't you just upvote that? If you have your own thoughts, surely you could just think them to yourself while upvoting.

yikes. I was responding to them sidestepping the first commenter’s question.

yikes.

Re: Show HN: Fructose – LLM calls as strongly typed functions

#92
post #80

Big proponent of guaranteed outputs for LLMs. I wrote a library awhile back (gpt-json) that did something similar by querying the OpenAI API. At the end of the day though while their responses are _highly likely_ to be valid JSON they're not guaranteed. There's only so much that can be done with remote calls to their model's black box. The future here really lies in compiling down context free grammars. They let you…

OpenAI lets you force valid JSON now

https://platform.openai.com/docs/guides/text-generation/json...

Re: Show HN: Fructose – LLM calls as strongly typed functions

#93
This is great, it might be really helpful for what I’ve been working on

Just put together a small project that uses GPT to find good job matches[1]

One of the most challenging things in making it useful for more users, is managing the prompt that include several pieces of user input, and need to return a specific format, with a structure that depends on what the user wants to include in the prompt

What’s the typical use case for this? Who needs it the most right now?

Thank you!

[1] https://news.ycombinator.com/item?id=39621373#39624542

Re: Show HN: Fructose – LLM calls as strongly typed functions

#94
post #92
post #80

Big proponent of guaranteed outputs for LLMs. I wrote a library awhile back (gpt-json) that did something similar by querying the OpenAI API. At the end of the day though while their responses are _highly likely_ to be valid JSON they're not guaranteed. There's only so much that can be done with remote calls to their model's black box. The future here really lies in compiling down context free grammars. They let you…

OpenAI lets you force valid JSON now https://platform.openai.com/docs/guides/text-generation/json...

valid json, yes, but not a specific json schema (yet, who knows, maybe they ship schema support, I'm surprised they haven't)

Re: Show HN: Fructose – LLM calls as strongly typed functions

#95

Earlier quoted context omitted.

Yeah the pyright doesn't like the annotated return type not being honored by the empty stub function. I wonder if there's a way to trick it. For your suggestion, the decorator would still be required to overload the function execution with the remote call, otherwise you'd just be calling the function body, but we have considered special wrapper return types to help play better with pyright (and also give programmatic…

> Yeah the pyright doesn't like the annotated return type not being honored by the empty stub function. I wonder if there's a way to trick it. Python has an existing convention for this (so its not a "trick"), the use of the special value Ellipsis (literal: ...) https://mypy.readthedocs.io/en/stable/stubs.html

[deleted]

Re: Show HN: Fructose – LLM calls as strongly typed functions

#96

Earlier quoted context omitted.

Yeah the pyright doesn't like the annotated return type not being honored by the empty stub function. I wonder if there's a way to trick it. For your suggestion, the decorator would still be required to overload the function execution with the remote call, otherwise you'd just be calling the function body, but we have considered special wrapper return types to help play better with pyright (and also give programmatic…

> Yeah the pyright doesn't like the annotated return type not being honored by the empty stub function. I wonder if there's a way to trick it. Python has an existing convention for this (so its not a "trick"), the use of the special value Ellipsis (literal: ...) https://mypy.readthedocs.io/en/stable/stubs.html

Beautiful, this does the trick!! Thanks for the tip.

  @ai()
  def stub() -> int:
      """docstring"""
      ...

  # (use ... instead of "pass" in the function body)

Re: Show HN: Fructose – LLM calls as strongly typed functions

#97
post #65

I find it grating that all of these types of things say "LLMs" when in fact they literally only work with OpenAI. There are hundreds of variations of LLM models. When it works with only gpt-4-turbo or gpt-3.5-turbo, it's inaccurate to say it's a tool for LLMs in general.

True, Grammar has been around with Llama.cpp since the early days IIRC. Microsoft had Guidance as well & now TGI supports it as well. End game for Langchain/Llamaindex if just guarantee or structure adherence was the only reason to use & beg the LLM for usable output.

Re: Show HN: Fructose – LLM calls as strongly typed functions

#99
post #80

Big proponent of guaranteed outputs for LLMs. I wrote a library awhile back (gpt-json) that did something similar by querying the OpenAI API. At the end of the day though while their responses are _highly likely_ to be valid JSON they're not guaranteed. There's only so much that can be done with remote calls to their model's black box. The future here really lies in compiling down context free grammars. They let you…

we don't need to limit ourselves to context-free, either. its possible to enforce scope as well, and even force per-token type correctness, as least for somewhat syntactically well-behaved languages that use local type inference.
Post reply on HN