# Fine-tuning LLM for RAG

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffine-tuning-llm-for-rag%2F91225%3E%5C
**Category:** Beginners\
**Created:** [June 10, 2024, 12:33am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffine-tuning-llm-for-rag%2F91225 "2024-06-10T00:33:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chahnwoo](https://avatars.discourse-cdn.com/v4/letter/c/a88e57/32.png) [@Chahnwoo](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FChahnwoo)%5C
**Post date:** [June 10, 2024, 12:33am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffine-tuning-llm-for-rag%2F91225%2F1 "2024-06-10T00:33:11Z")

</div>

I am currently fine-tuning a LLM with a custom QA dataset, and was wondering whether there would be a significant difference whether I ran QLoRA fine-tuning with a model initialized with **AutoModelForCausalLM** and a model initialized with **AutoModelForQuestionAnswering**. If there does exist a significant difference, which of the two is preferrable?

For additional context, the dataset I will be fine-tuning with consists of three columns: _question_, _context_, and _answer_. The three columns are then formatted with a prompt along the lines of

```auto
### Instruction
Use the context below to generate an answer to the provided question. If the context does not contain sufficient information, state that an answer could not be found.

### Context
{context}

### Question
{question}

### Response
{response}

```

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fnielsr)%5C
**Post date:** [June 10, 2024, 7:14am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffine-tuning-llm-for-rag%2F91225%2F2 "2024-06-10T07:14:00Z")

</div>

Hi,

The difference is generative vs. extractive question answering.

The **AutoModelForQuestionAnswering** class is meant for extractive question answering, i.e. the model is a classifier and needs to determine which text token of the context is at the start of the answer and which part of the context is at the end.

The **AutoModelForCausalLM** classs is meant for generative question answering, i.e. the model is a generative model (like ChatGPT) and can generate any text given the context + question. This means that the model can give answers that go beyond the literate text of the context.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/hellohellohello/original/2X/d/de4155eb4aa4108ecb32a1389d7cc37ae69f88b7.png) [@system](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsystem)%5C
**Post date:** [June 18, 2024, 12:08am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ffine-tuning-llm-for-rag%2F91225%2F3 "2024-06-18T00:08:03Z")

</div>

Closed on June 18, 2024, 12:08am UTC

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
