Lurker News
There is a 5 month old thread [1] on this, but it might be already outdated.

What is the best approach for feeding custom set of documents to LLM and get non-halucinating and decent result in Dec 2023?
UPD: The question is generally about how to "teach" LLM answer questions using your set of documents (not necessarily train your own, so approaches like RAG counts)
[1] https://news.ycombinator.com/item?id=36832572

Comments (237) 63 threads

Earlier comments
vikbehal#
Hello,

I am currently working on a demo use-case to generate documents, and I intend to feed a few documents as sample. E.g., Say a leasing documents. Such document will vary by leasing company, state, etc. so there is not 1 template.
I do understand that I could create embeddings for each template and then use them to ask ChatGpt to generate documents where certain entities would change. I've setup a basic project but I am stuck at stage where I don't know how to tell ChatGpt that provided documents are sample and it needs to generate similar ones based on prompt engineering.

kmkarim5 replies#
Slightly off topic but is there recommended advice on how to tune / train not for document retrieval but for consistent JSON output with specific enums?

i.e given a text, always return back a certain set of fields. For some keys here is the possible set of enums etc. One shot prompting does work but curious how others approach this if you have training data on hand.

techn00#
You want grammars to restrict the output, search for "gbnf grammar". That and combined with a good prompt with an example, also check out outlines.dev
simonw#
For OpenAI, use their functions schema mechanism.

Aside from that, take a look at llama.cpp grammars.

ukuina1 reply#
Microsoft Guidance will do this.
Der_Einzige#
Seems Microsoft spun them out and gave them independence. Not sure why, given it's the kind of IP that helps keep microsoft dominant.
michaelt1 reply#
Ask the model nicely, check any json in the output against your schema, regenerate if it doesn’t match.

Crude, I know, but it’s compatible with every model. Which is useful if you want to compare the many different models out there.

mark_l_watson#
That is a fairly good strategy. Six years ago at Capital One, I experimented with generating synthetic JSON AWS CloudWatch files for testing (that would not contain any sensitive information). Way back then I used LSTM models and I simply had code to check output and only keep valid samples.

LLMs are so much better for this than LSTMs now.

ParetoOptimal1 reply#
I need to give Khoj a try again. I tried it on my org inbox on a whim, couldn't get useful results, and promptly forgot about it.
npamart#
Nice pun
xnx2 replies#
GPT-4 Turbo has a 128K (~300 pages) context window, which probably handles a lot of use cases which might have previously needed extra training/refinement.
mettamage2 replies#
The chatgtp app says it has a context window of 4096 tokens (gpt 4). How do I get access to turbo?
SgtBastard#
The gpt-4-1106-preview (aka gpt-4-turbo) is a foundational model with a 128K context window that OpenAI makes available for API consumption both directly and via Azure OpenAI Services.

ChatGPT is a consumer facing service that wraps the GPT-4 foundational model but at some point will likely wrap gpt-4-turbo.
Signing up for OpenAI API access or Azure OpenAI Services will grant you access to this model (with some rate-limits in place given its a preview model).

coder543#
If you're asking ChatGPT about its own characteristics, you should not believe the responses. Models can't examine themselves, so unless the model was trained on specific information about itself, or unless the info is put into the System Prompt, then it cannot know the answer. A response indicating 4096 tokens would just be a hallucination, or a misunderstanding based on training data that saw references to what older versions of ChatGPT were trained on.

ChatGPT-4 is powered by GPT-4 Turbo at this point, so it has a context window that is much larger than 4096 tokens, whether it knows it or not. The ChatGPT application may limit the context size from reaching the full 128k to keep costs down, and it will be using some of the context window for its own purposes, but it's certainly able to maintain context across more than 4096 tokens of conversation.

Der_Einzige1 reply#
Long context length models are still mostly a mirage with the "lost in the middle" phenomenon rearing it's ugly little head on actual production use-cases of this.
KaoruAoiShiho1 reply#
Not true.
ametrau1 reply#
Huh? Obviously true. You can not have tried it.

Continue this thread — 1 reply

Load more comments