Viewing a single comment thread. View all comments

LetGoAndBeReal t1_je65ffo wrote

The comments here so far have addressed three possible approaches to this. Two of those approaches - ie training your own model and fine-tuning an existing model - are not currently viable. Training your model would require a ridiculous amount of human and compute power and not result in something where data could be easily added. Fine-tuning a model does not result in the model absorbing new data - it only conditions the output patterns from the model using data/knowledge the model gained during initial training.

The only viable approach is to use retrieval augmented generation, where data relating to user questions are retrieved from outside the model and fed to model as part of the prompt. Tools like LangChain can help you build a RAG solution on your own. There are also many services coming out that provide this sort of capability, such as humata.ai.

86

Im_Unlucky t1_je6hn68 wrote

This is the way ^

  1. shove data into vector db
  2. embed incoming query
  3. return topk matches from vector db
  4. inject those into prompt
  5. make api call to openai
  6. display response
  7. ???
  8. you are now a ML engineer
62

Hands0L0 t1_je6o5t5 wrote

Off topic but I love how underpants gnomes memes are still relevant 25 years later

26

visarga t1_je6k74d wrote

Often it seems that the model can't properly synthesise information from a bunch of snippets, it lacks the context of those snippets, so it will combine the information incorrectly or hallucinate an explanation.

Retrieval + loading data in the context is far from solved.

16

Im_Unlucky t1_je6vjqd wrote

This is true. Good prompt engineering has definitely gone a long way for me in improving rag performance though. I don’t think shoving snippets into the prompt is the long term solution, but at this point in time it’s the best option in my experience.

8

kromem t1_je6uv46 wrote

"Moar layers" doesn't only need to apply to the NN.

CoT prompting works by breaking analysis down into smaller steps that each generate their own additional context.

Doing something similar with DB analysis is absolutely possible, such as preemptively summarizing schema and using that summary as part of the retrieval to contextualize the specific fragments.

Additionally, having static analysis examples on hand for related tables that's fed in to go from zero shot to few shot would go a long way at reducing some of the issues you highlight.

6

Tostino t1_je847jg wrote

Literally just worked through this today manually as a proof of concept, using the LLM to augment the DB schema with comments describing any relevant info or corner cases. I'm essentially just manually feeding it as context to my prompts when I need to know something related to that set of tables, but it seems pretty powerful. Automating this is going to be nuts.

5

kromem t1_je84zam wrote

> Automating this is going to be nuts.

Yes, yes it is.

6

Cantareus t1_je6vn79 wrote

>shove data into vector db
>
>embed incoming query
>
>return topk matches from vector db

Can these steps be done through the openai API?

You only reply using JSON. Write 5 queries that will return useful data to aid you in answering the users questions "What was Apple’s return compared to it’s sector last month" return in JSON array with no explanations. Each query must run independently. Use the return format [{"Reason":"Why the query is useful","query":"The sql query"}] The schema is:

(Imagine a valid schema is here)

GPT-4 Response:

[

{

"Reason": "Retrieve Apple's stock return last month",

"query": "SELECT stock_return FROM stocks WHERE company = 'Apple' AND date >= DATEADD(month, -1, GETDATE()) AND date < GETDATE();"

},

{

"Reason": "Retrieve sector for Apple",

"query": "SELECT sector FROM companies WHERE company_name = 'Apple';"

},

{

"Reason": "Retrieve companies in Apple's sector",

"query": "SELECT company_name FROM companies WHERE sector = (SELECT sector FROM companies WHERE company_name = 'Apple');"

},

{

"Reason": "Calculate average return for Apple's sector last month",

"query": "SELECT AVG(stock_return) as sector_return FROM stocks WHERE company IN (SELECT company_name FROM companies WHERE sector = (SELECT sector FROM companies WHERE company_name = 'Apple')) AND date >= DATEADD(month, -1, GETDATE()) AND date < GETDATE();"

},

{

"Reason": "Compare Apple's return to the average return of its sector last month",

"query": "SELECT (SELECT stock_return FROM stocks WHERE company = 'Apple' AND date >= DATEADD(month, -1, GETDATE()) AND date < GETDATE()) - (SELECT AVG(stock_return) as sector_return FROM stocks WHERE company IN (SELECT company_name FROM companies WHERE sector = (SELECT sector FROM companies WHERE company_name = 'Apple')) AND date >= DATEADD(month, -1, GETDATE()) AND date < GETDATE()) as comparison;"

}

]

5

jaxolingo OP t1_je7c63z wrote

Cool, this is exactly the approach I had in mind that the model would take

5

gstatton t1_je7mwmv wrote

I’ve done something similar to this, but I created a view in snowflake, dumped the ‘describe table <table-name>’ to CSV, used that CSV descriptor in the head of the prompt, and asked the LLM to generate a SQL query from the user’s question using the provided table schema…I’ll take the model’s return and pass it directly to snowflake, return it as a data frame, and then send that back to the LLM to get a text summary of the query results

You can also use LangChain to set up the chain to do this automatically..

3

qncapper t1_jebjy9s wrote

Cool, how can I be confident about my model not spewing sh*t or not making up things on the fly, cause what it gives out has impact on my stakeholders.

1

machineko t1_je70llx wrote

Why would you say that fine-tuning is not viable? There are many production use cases of fine-tuning a model using in-house proprietary data.
If fact, if you have the resources you can do both fine-tuning of an existing model (whether is just supervised or unsupervised) and also use that for retrieval augmented generation.

10

LetGoAndBeReal t1_je71r0g wrote

Fine-tuning can be great for getting better output from the model based on the knowledge that model already contains. I only meant fine-tuning is not viable for getting new data/knowledge into a model. Fine-tuning does not accomplish knowledge absorption.

3

WokeAssBaller t1_je7y09s wrote

Huh? I think that depends on the fine tuning you are talking about. Fine tuning can absolutely add knowledge to a model

8

lgastako t1_je8i6dw wrote

Not generally very well.

−1

WokeAssBaller t1_jea0ubd wrote

Fine tuning is additional training, there are lots of ways of doing that and sometimes it’s absolutely ideal, there are tradeoffs

1

lgastako t1_jea7kb3 wrote

Would love to see an example of it adding knowledge effectively. I haven't been able to find any at all.

1

WokeAssBaller t1_jealxm2 wrote

Train one from scratch

1

lgastako t1_jeayn8v wrote

I know training a model from scratch will work, but the context of the conversation is fine tuning an existing model and I'm saying I would love to see examples of the claims people are making actually working, because I have only been able to find and create examples of it not working very well at all.

1

WokeAssBaller t1_jebpjog wrote

fine tuning is just additional training, so if it works from scratch it works with fine tuning. And no it may not be as effective as other methods but the poster was claiming it was impossible

1

machineko t1_je83m8x wrote

Unsupervised fine-tuning (or extending the pre-training) with additional data will work. Of course, how to get it to learn new information effectively is a challenge but not impossible.

2

Goldenier t1_je9uruu wrote

This is false, and actually most of the time the opposite is the problem: the model learns too much of the new data it's finetuned on (overfitting on it), but forgets the "knowledge" in the original model. The simplest and most popularly used example right now is when you use the dreambooth, Lora or other finetuning methods to finetune parts of the big image diffusion models and if you overtrain it will place the newly trained face or object in almost all of it's output, so it easily learns new data but also easily forgets old one. ( One mitigation for this is to use preservation loss to make sure it also keeps the old knowledge. ) And there is no reason why the same methods wouldn't work on LLMs too, for example there is already Lora for LLMs too.

2

LetGoAndBeReal t1_je9zfyb wrote

>And there is no reason why the same methods wouldn't work on LLMs too, for example there is already Lora for LLMs too.

It's really not helpful to make strong assertions like this without referring to specific, verifiable sources. Fine-tuning very typically is done in a way where certain layers/parameters of the model are frozen. This is done to avoid the sort of loss we are discussing. The LoRA paper itself states that LoRA "freezes the pre-trained model weights".

0

light24bulbs t1_je7ilvq wrote

I disagree that it's not viable to train a model. The problem is that the best public model (llama) is non-commercial.

That said, it's extremely possible to train things into it. There's a ton of new scripts floating around online. The Lora training is especially good.

The trouble with vectors is they are so limited. They're fine if you need to look up one distinct thing (and the vector gets the match right) but they're utterly useless if you'd like the model to learn about something in general.

9

LetGoAndBeReal t1_je7m1tq wrote

Take a closer look at every script/blog/video related to fine-tuning a model and you will see it doesn’t involve adding new knowledge to the model. If you find an exception I’d be delighted to see it.

2

light24bulbs t1_je7mr9p wrote

False, they all do. The process of fine-tuning is identical to the initial pre-training, though perhaps with different settings. They're mostly setup to take q&a data for getting llama to take instructions better, but actually that's just text wrapped in some context and passed in straight up.

I was very confused by this as well but no, you can train new stuff.

−1

LetGoAndBeReal t1_je7n1gc wrote

Instead of seeing who can talk more loudly about who’s right, why don’t you post a link of a script that does this.

3

light24bulbs t1_je7ob17 wrote

Okay, here's my friend turning the alpaca instructions into training data

https://github.com/lxe/llama-peft-tuner/blob/main/convert_alpaca_to_text.py

See how it's just turning it into a fat string?

1

LetGoAndBeReal t1_je7p0l8 wrote

In what way does this show that new knowledge was added to a large language model?

2

light24bulbs t1_je7pnxa wrote

This IS training. That's what it is. This is how "knowledge" got into the model in the first place

2

LetGoAndBeReal t1_je7re7y wrote

Of course the fine-tuning data itself can have knowledge not in the model - that doesn’t prove anything.

What you need to show is that knowledge presumably added during fine-tuning was then retrieved from the model after fine-tuning.

0

light24bulbs t1_je7sn5e wrote

The fact that the fine tuning can improve instruction following is EXACTLY that. There's no distinction between predicting the next word, following instructions, or deep knowledge. They are all the same thing as far as an LLM.

3

WokeAssBaller t1_je7y7ij wrote

Lol this guy doesn’t understand ML, you are absolutely adding knowledge to the model

−1

light24bulbs t1_je863pu wrote

Yeah, he doesn't get it. That's ok though, but to be wrong and be sure about it is a bummer

0

LetGoAndBeReal t1_je8akb1 wrote

I would agree with that last statement. You think you understand this, but you don’t seem to understand what does and doesn’t happen during fine-tuning or to realize that the problem of adding knowledge to LLMs is a notoriously difficult problem that ongoing research is trying to solve.

Try looking at some of the research: https://openreview.net/forum?id=vfsRB5MImo9

Or read what OpenAI says fine-tuning accomplishes: https://platform.openai.com/docs/guides/fine-tuning

Or, better yet, try actually getting a LLM to learn new facts by fine-tuning it. Then you will understand.

4

elbiot t1_je8i0i2 wrote

The second link says fine tuning is a substitute for lengthy prompts, including putting more into it than can fit in the longest prompt. Prompts are a way to give the model new information. What is your definition of knowledge that isn't something you can put into a prompt?

2

LetGoAndBeReal t1_je8j7hw wrote

The key word in that OpenAI link is “examples”. It says “more examples” and not “more knowledge”, because it’s referring to few shot training, which is about conditioning rather than providing new data.

In other words, if you want to get the model to classify sentiment of user comments as positive or negative, you can provide several examples in the prompt of both positive and negative comments. Fine-tuning allows you to provide many more such examples to the model than can fit in a prompt.

The key point is that through fine-tuning these examples can condition the model to classify sentiment but do not cause new facts to be absorbed by the model. You cannot get new facts to be readily absorbed through fine-tuning, which is why the OP should not look to fine-tuning to endow the model with the external dataset they want to use for question answering.

1

elbiot t1_je8ngu2 wrote

Huh? Have you never included text in a prompt and asked it to answer questions about the text? Seems like that counts as "new knowledge" by your definition

1

LetGoAndBeReal t1_je9a3hb wrote

Of course, that’s what allows RAG to work in the first place. I didn’t say you couldn’t provide new knowledge through the prompt. I only said you cannot provide new knowledge through the fine-tuning data. These are two completely separate things. This distinction is the reason RAG works for this use case and fine-tuning does not.

1

elbiot t1_je9s53t wrote

Your claim that prompting can achieve what fine tuning can't contradicts the documentation for openai that you posted that said fine tuning can do whatever prompting can without the length limit

1

LetGoAndBeReal t1_jea1id9 wrote

I believe you are referring to this statement from the link: "Ability to train on more examples than can fit in a prompt." Correct?

If so, as I explained, the key word here is "examples." And if you understand why, you will see that there is no contradiction. I will try to clarify why.

There are two methods that we are discussing for extending the capability of an LLM:

  1. Prompt engineering
  2. Fine-tuning

There are also different types of capability that might be extended. We are discussing the following two:

  1. Adding new knowledge/facts to the model
  2. Improving downstream processing tasks, such as classification, sentiment analysis, etc.

Both of these capabilities are readily done through prompt engineering. Adding new knowledge with prompt engineering involves including that knowledge as context in the prompt. Improving tasks such as classification is done by include examples of the processing you want done in the prompt.

What the article says is that for the case where you want to provide examples in the prompt to make the model perform better, you can alternatively use fine-tuning. The article does not say "Ability to add more knowledge than can fit in a prompt." Examples = downstream processing tasks. Examples != new knowledge.

1

WokeAssBaller t1_jea0o2f wrote

Again you are using an incredibly limited definition of fine tuning based on what the open ai api allows, which once again tells me you don’t know ML.

Fine tuning is ANY additional training on a foundational model, this can be MLM training on the model base or selectively training the subsequent layers.

OF COURSE this can add knowledge as you are doing the same training that got it knowledge in the first place. Glad to see you jumped on the chatgpt band wagon last week, build a transformer from scratch and come talk to me

2

light24bulbs t1_je8d6bh wrote

Continuous retraining is something else.

I'll be training llama soon, I'll get back to you with how it goes.

1

LetGoAndBeReal t1_je8m6y9 wrote

Include new factual statements in your training data like “Joe Biden’s cat is named Fluffy.” Ask the model the name of Joe Biden’s cat before and after training and let us know the answers you get back. See if you get reliable answers across a set of data/questions.

2

WokeAssBaller t1_je7yeux wrote

This is a fine approach but fine tuning can and does add knowledge to models, please quit saying that

2

LetGoAndBeReal t1_je9c66v wrote

Instead of insisting that fine-tuning reliably adds new knowledge to an LLM, why not instead show some evidence of this claim. Per my links above, this is a notoriously challenging problem in ML.

Apart from these resources, let's think critically for a second. If the approach were viable at this point, then there would be tons of commercial solutions using fine-tuning instead of RAG for incorporating external knowledge in an LLM application. Can you find even one?

2

WokeAssBaller t1_jea17d0 wrote

Why don’t you actually implement a transformer from scratch and then speak more confidently, this is like talking to a virgin about sex.

0

valjestir t1_je8w22c wrote

RAG is exactly what OP needs here. I don’t think Langchain has any way to connect to Azure of Snowflake though so they still need some way to extract that data.

A project I’m working on helps with ETL for retrieval augmented generation: https://github.com/ai-sidekick/sidekick

1