Downloads · 30 days
0
gcw-ai/gemma-scappy-qatar-adapter
gemma-scappy-qatar-adapter is a machine learning model from gcw-ai. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as gemma.
This is fine-tuned QLora adapter of Gemma 7B base model using Python Code Critic 21K Dataset.
Downloads · 30 days
0
Access
Public
Updated Apr 14, 2024
Repo size
122 MB
Likes
0
Public
Click a slice to open those files.
.safetensors100 MB · 79%
From the Hugging Face model README
This is fine-tuned QLora adapter of Gemma 7B base model using Python Code Critic 21K Dataset.
This is trained for Python code agent SCAPPY (Self Critic Agent for Programming in Python) which is submitted for Kaggle Challenge Google-AI Assistants for Data Tasks with Gemma
SCAPPY QATAR adapter verifies the code and generates improved responses when necessary. It takes a question and an answer as input and outputs a consideration (thought), appropriateness judgment (action), and an improved answer (revised answer). (QATAR: Question, Answer -> Thought, Action, Revised Answer)
The process of the SCAPPY is as follows <img src="https://huggingface.co/gcw-ai/gemma-scappy-qatar-adapter/resolve/main/images/img_1_1.png" alt="overview">
Example code to use SCAPPY QATAR adapter is as follows:
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
from peft import PeftModel
base_id = "google/gemma-7b"
peft_id_7b_qatar = "gcw-ai/gemma-scappy-qatar-adapter"
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16
)
base_model = AutoModelForCausalLM.from_pretrained(base_id, quantization_config=bnb_config, device_map={"":0})
tokenizer = AutoTokenizer.from_pretrained(base_id)
model = PeftModel.from_pretrained(base_model, peft_id_7b_qatar, adapter_name="qatar")
instruction = f"""Write a function to add the given list to the given tuples.
Evaluate the following test cases with print.
add_lists([5, 6, 7], (9, 10)) == (9, 10, 5, 6, 7)
add_lists([6, 7, 8], (10, 11)) == (10, 11, 6, 7, 8)"""
answer_txt = """Here is the implementation of the requested function:
```python
def add_lists(list1, tuples):
return tuples + list1
```
Explanation:
- The function `add_lists` takes two arguments, `list1` which is a list, and `tuples` which is a tuple.
- The function concatenates the `tuples` and `list1` using the `+` operator, which returns a new tuple with the elements of both the tuple and the list combined.
- The function returns the concatenated tuple.
Test cases:
```python
print(add_lists([5, 6, 7], (9, 10))) # Output: (9, 10, 5, 6, 7)
print(add_lists([6, 7, 8], (10, 11))) # Output: (10, 11, 6, 7, 8)
```"""
execution_result = """Error: TypeError: can only concatenate tuple (not "list") to tuple"""
qatar_prompt = f"@@@ Instruction:{instruction}\n\n@@@ Output:{answer_txt}\n\n@@@ Execution Result:{execution_result}\n\n@@@ Thought:"
inputs = tokenizer(qatar_prompt, return_tensors="pt").to("cuda:0")
outputs = model.generate(**inputs, max_new_tokens=1000)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
The Result of the example code is as follows
@@@ Instruction:Write a function to add the given list to the given tuples.
Evaluate the following test cases with print.
add_lists([5, 6, 7], (9, 10)) == (9, 10, 5, 6, 7)
add_lists([6, 7, 8], (10, 11)) == (10, 11, 6, 7, 8)
@@@ Output:Here is the implementation of the requested function:
```python
def add_lists(list1, tuples):
return tuples + list1
```
Explanation:
- The function `add_lists` takes two arguments, `list1` which is a list, and `tuples` which is a tuple.
- The function concatenates the `tuples` and `list1` using the `+` operator, which returns a new tuple with the elements of both the tuple and the list combined.
- The function returns the concatenated tuple.
Test cases:
```python
print(add_lists([5, 6, 7], (9, 10))) # Output: (9, 10, 5, 6, 7)
print(add_lists([6, 7, 8], (10, 11))) # Output: (10, 11, 6, 7, 8)
```
@@@ Execution Result:Error: TypeError: can only concatenate tuple (not "list") to tuple
@@@ Thought:The provided answer contains a function that attempts to concatenate a list and a tuple, which is not possible in Python. The error in the execution result is due to the attempt to concatenate a list and a tuple, which is not supported in Python. The correct approach would be to convert the list to a tuple before concatenation.
@@@ Action:fail
@@@ Revised Answer:To add a list to a tuple, you need to convert the list to a tuple first. Here is the corrected implementation of the function:
```python
def add_lists(list1, tuples):
return tuples + tuple(list1)
```
Explanation:
- The function `add_lists` takes two arguments, `list1` which is a list, and `tuples` which is a tuple.
- The function converts the `list1` to a tuple using the `tuple()` function.
- The function concatenates the `tuples` and the converted `list1` using the `+` operator, which returns a new tuple with the elements of both the tuple and the list combined.
- The function returns the concatenated tuple.
Test cases:
```python
print(add_lists([5, 6, 7], (9, 10))) # Output: (9, 10, 5, 6, 7)
print(add_lists([6, 7, 8], (10, 11))) # Output: (10, 11, 6, 7, 8)
```