File size: 4,741 Bytes
e15f272
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
---

license: apache-2.0
base_model: Ilides/coser-1-by-ilides
tags:
  - coser-1.1-code
  - ilides
  - coding-assistant
  - qwen3.5
  - lora
language:
  - en
pipeline_tag: text-generation
---


# Coser 1.1-code by ilides (HF Safetensors)

**Coser 1.1-code** es la evoluci贸n de [Coser 1](https://huggingface.co/Ilides/coser-1-by-ilides), fine-tuned con **2,000 ejemplos de c贸digo** de datasets p煤blicos (Code-Feedback, CodeAlpaca, Magicoder, CodeInstruct).

Publicado por **[ilides](https://huggingface.co/Ilides)**.

## Versiones disponibles

| Repositorio | Formato | Uso |
|-------------|---------|-----|
| [Ilides/coser-1.1-code](https://huggingface.co/Ilides/coser-1.1-code) | Safetensors (HF) | Transformers, fine-tuning |
| [Ilides/coser-1.1-code-GGUF](https://huggingface.co/Ilides/coser-1.1-code-GGUF) | GGUF Q8_0 / F16 | llama.cpp, LM Studio |



## Stats de entrenamiento



| M茅trica | Valor |

|---------|-------|

| Base | Coser 1 by ilides (Qwen3.5-0.8B) |

| Dataset | 2,000 ejemplos c贸digo |

| M茅todo | LoRA r=16 + QLoRA 4-bit |

| Steps | 181 |

| Loss | 0.8206850051879883 |

| Token accuracy | 79.2% |

| Tiempo | None min |

| GPU | NVIDIA GeForce RTX 3050 |



## Benchmark real (NVIDIA GeForce RTX 3050)



| Prompt | tok/s |

|--------|-------|

| Write a Python function that reverses a linked lis... | 17.0 |

| Write a JavaScript async function to fetch and par... | 22.0 |

| Explain what binary search is and write it in Pyth... | 21.5 |

| Write a SQL query to find duplicate emails in a us... | 19.4 |

| Fix this bug: my Python function returns None inst... | 21.8 |

| **Promedio** | **20.3** |



## Ejemplos reales



### Write a Python function that reverses a linked list.



```

```python

class Node:

    def __init__(self, val):

        self.val = val

        self.next = None



def reverse_linked_list(head):

    prev = None

    curr = head

    while curr:

        next_node = curr.next
        prev.next = curr

        curr.next = prev

        prev = curr

        curr = next_node

    return prev

```

```


### Write a JavaScript async function to fetch and parse JSON from an API.

```

```javascript
async function fetchJsonAPI(url) {
  // Fetch the JSON data from the API
  const response = await fetch(url);
  const data = await response.json();

  // Handle any potential errors or exceptions
  if (!data) {
    console.error("Error fetching JSON from API");

    return null;

  }


  // Process the JSON data as needed
  // For example, convert to a dictionary, parse a JSON object, or store in an array
  // Process the data here
  // ...

  return data;
}
```

```

### Explain what binary search is and write it in Python.

```

Binary search is a search algorithm that takes an array of elements and returns the index of the target element in the array. It has the following properties:



1. It operates on the sorted elements of the array.

2. It has a time complexity of O(log n), which is very efficient.

3. It uses two pointers, one starting at the beginning of the array and the other at the end.



In Python, we can use the built-in `bisect` module to implement binary search. The `bisect.bisect_left` function returns the insertion point for a given value in a sorted list, and the `bisect.bisect_right` function returns the insertion point for a given value just after the insertion point of the previous value.



Here is a Python code snippet that demonstrates binary search using the `bisect` module:



```python

import bisect



# Given sorted array

arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]



# Search for a value in the arr

```


## Uso (Transformers)

```python

from transformers import AutoModelForCausalLM, AutoTokenizer

import torch



model_id = "Ilides/coser-1.1-code"

tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)

model = AutoModelForCausalLM.from_pretrained(

    model_id, device_map="auto", trust_remote_code=True, torch_dtype=torch.bfloat16

)

messages = [

    {"role": "system", "content": "You are Coser 1.1-code by ilides, an expert AI coding assistant."},

    {"role": "user", "content": "Write a Python function to reverse a string."},

]

text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)

inputs = tokenizer(text, return_tensors="pt").to(model.device)

out = model.generate(**inputs, max_new_tokens=256, temperature=0.7)

print(tokenizer.decode(out[0], skip_special_tokens=True))

```

## Cr茅ditos

- Base: [Ilides/coser-1-by-ilides](https://huggingface.co/Ilides/coser-1-by-ilides)
- Datasets: Code-Feedback, python_code_instructions, CodeInstruct-20K, magicoder-python-5k
- Autor: ilides