This commit is contained in:
Jason Liu
2023-10-14 16:12:15 -04:00
parent d454ef34e8
commit af1f3410f6
2 changed files with 7 additions and 6 deletions
+2 -1
View File
@@ -16,7 +16,7 @@ But the promise of LLMs is that they can do all of this in one go. So how do we
## Challenges in Fine-tuning
Fine-tuning a model isn't as straightforward as just writing `def f(a, b): return a * b` to teach a model three-digit multiplication. Substantial data preparation is required, making logging for data collection cumbersome. Luckily OpenAI not only provides a fine-tuning script but also one for function calling which simplies the process backed to structured outputs! More over, the finetune allows us to avoid passing the schema to the model, resulting in less tokens being used!
Fine-tuning a model isn't as straightforward as just writing `def f(a, b): return a * b` to teach a model three-digit multiplication. Substantial data preparation is required, making logging for data collection cumbersome. Luckily OpenAI not only provides a fine-tuning script but also one for function calling which simplies the process backed by structured outputs! More over, the finetune allows us to avoid passing the schema to the model, resulting in less tokens being used!
## Role of Instructor in Easing the Process
@@ -28,6 +28,7 @@ Here's an example to illustrate its use:
```python
import logging
import random
from pydantic import BaseModel
from instructor import Instructions
+5 -5
View File
@@ -27,15 +27,15 @@ instructions = Instructions(
log_handlers=[logging.FileHandler("math_finetunes.jsonl")]
)
class Response(BaseModel):
class Multiply(BaseModel):
a: int
b: int
result: int
@instructions.distil
def fn(a: int, b: int) -> Response:
def fn(a: int, b: int) -> Multiply:
resp = a + b
return Response(a=a, b=b, result=resp)
return Multiply(a=a, b=b, result=resp)
```
## Custom Log Handlers for Data Collection
@@ -85,9 +85,9 @@ instructions = Instructions(
)
@instructions.distil(model='gpt-3.5-turbo:finetuned', swap=True)
def fn(a: int, b: int) -> Response:
def fn(a: int, b: int) -> Multiply:
resp = a + b
return Response(a=a, b=b, result=resp)
return Multiply(a=a, b=b, result=resp)
```
This dynamic switching retains backward compatibility while improving efficiency, opening up exciting avenues for future developments.