| ---
|
| 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
|
|
|