# Fine tuning a LLM with a code

**URL:** <https://discuss.huggingface.co/t/fine-tuning-a-llm-with-a-code/70353>\
**Category:** Models\
**Created:** [January 24, 2024, 5:03am UTC](https://discuss.huggingface.co/t/fine-tuning-a-llm-with-a-code/70353 "2024-01-24T05:03:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Venushki](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/venushki/32/23091_2.png) [@Venushki](https://discuss.huggingface.co/u/Venushki)\
**Post date:** [January 24, 2024, 5:03am UTC](https://discuss.huggingface.co/t/fine-tuning-a-llm-with-a-code/70353/1 "2024-01-24T05:03:04Z")

</div>

I want to fine-tune a LLM locally to serve as an intelligent code reviewer to use as a tool for developers that, given natural language descriptions, identifies and highlights specific locations in the C# codebase where changes are needed. The goal is to streamline the code review process by providing developers with precise indications of where modifications should be made based on their high-level descriptions. Even though there are suitable LLMs for the task i can’t figure out a way to feed my C# code base to the LLM. (a way for the LLM to read my code files )

---

<div class="post-metadata">

**Author:** ![AbishekSundar](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@AbishekSundar](https://discuss.huggingface.co/u/AbishekSundar)\
**Post date:** [January 24, 2024, 6:41am UTC](https://discuss.huggingface.co/t/fine-tuning-a-llm-with-a-code/70353/2 "2024-01-24T06:41:32Z")

</div>

Are you looking to train any specific LLM? I had used GPT2 for a similar task and it worked decently well.

---

<div class="post-metadata">

**Author:** ![Venushki](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/venushki/32/23091_2.png) [@Venushki](https://discuss.huggingface.co/u/Venushki)\
**Post date:** [January 24, 2024, 7:06am UTC](https://discuss.huggingface.co/t/fine-tuning-a-llm-with-a-code/70353/3 "2024-01-24T07:06:00Z")

</div>

yes i was thinking code llama or mistral 7b (i can use any open source LLM that supports a C# code base)… how did you feed your code base into the llm to fine tune it to learn the code?

---

<div class="post-metadata">

**Author:** ![AbishekSundar](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@AbishekSundar](https://discuss.huggingface.co/u/AbishekSundar)\
**Post date:** [January 24, 2024, 7:13am UTC](https://discuss.huggingface.co/t/fine-tuning-a-llm-with-a-code/70353/4 "2024-01-24T07:13:15Z")

</div>

I had created a dataloader function and used huggingface’s trainer function. I used GPT2 and not mistral or code llama.

---

<div class="post-metadata">

**Author:** ![Venushki](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/venushki/32/23091_2.png) [@Venushki](https://discuss.huggingface.co/u/Venushki)\
**Post date:** [January 24, 2024, 9:14am UTC](https://discuss.huggingface.co/t/fine-tuning-a-llm-with-a-code/70353/5 "2024-01-24T09:14:42Z")

</div>

can you explain the function or maybe give me the code?

---

<div class="post-metadata">

**Author:** ![aakashgoel12](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@aakashgoel12](https://discuss.huggingface.co/u/aakashgoel12)\
**Post date:** [February 27, 2024, 9:00am UTC](https://discuss.huggingface.co/t/fine-tuning-a-llm-with-a-code/70353/6 "2024-02-27T09:00:51Z")

</div>

@Venushki @AbishekSundar Please share approach/code taken to prepare dataset like schema which is feeded into data loader.

---

<div class="post-metadata">

**Author:** ![CafferyChu](https://avatars.discourse-cdn.com/v4/letter/c/d78d45/32.png) [@CafferyChu](https://discuss.huggingface.co/u/CafferyChu)\
**Post date:** [April 25, 2024, 8:48am UTC](https://discuss.huggingface.co/t/fine-tuning-a-llm-with-a-code/70353/7 "2024-04-25T08:48:14Z")

</div>

Any update here? I’m working on a similar task. But have no idea how to feed code file to llm. Do I need create a dataset with comment like what the function is doing? or just feed the code file to mode? Anyone can help?

Thanks,  
Caffery

---

<div class="post-metadata">

**Author:** ![lcarrere](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lcarrere/32/40469_2.png) [@lcarrere](https://discuss.huggingface.co/u/lcarrere)\
**Post date:** [February 5, 2025, 7:28pm UTC](https://discuss.huggingface.co/t/fine-tuning-a-llm-with-a-code/70353/8 "2025-02-05T19:28:26Z")

</div>

– Disclaimer: I’m the main developer of this product –

[LM-Kit.NET](http://LM-Kit.NET) offers a straigforward API to infer and finetune LLMs locally.

You can find a fine-tuning demo from this link: github. com/LM-Kit/lm-kit-net-samples/tree/main/console\_net6/finetuning

To obtain a free community license: [Community Edition Licensing Overview | LM-Kit](https://lm-kit.com/products/community-edition/)

If you need further information or assistance on this topic I’ll be more than happy to assist.
