- What it is: A collection of elements stored in contiguous memory locations. Elements are accessed by their index.
- Why learn it: Arrays are one of the simplest and most fundamental data structures. They are the building block for many other structures, like lists in Python.
- Operations: Insertion, deletion, accessing an element by index.
- Time complexity:
- Access: O(1)
- Insert/Delete (at the end): O(1)
- Insert/Delete (at the start or middle): O(n)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from sklearn.feature_extraction.text import TfidfVectorizer | |
from sklearn.metrics.pairwise import cosine_similarity | |
from sentence_transformers import SentenceTransformer | |
class HybridSearch: | |
def __init__(self, documents): | |
self.documents = documents | |
# Initialize keyword search (TF-IDF) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
CGM Spike Detection Algorithm | |
This module provides functions to analyze Continuous Glucose Monitoring (CGM) data | |
and detect various patterns including rapid rises, sustained high periods, | |
meal responses, and hypoglycemic events. | |
""" | |
import pandas as pd | |
import numpy as np |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mlx_lm import load | |
import mlx.core as mx | |
import mlx.nn as nn | |
from mlx_lm.utils import (cache, maybe_quantize_kv_cache) | |
from mlx_lm.models.base import create_attention_mask | |
from mlx_lm.sample_utils import make_sampler | |
from tqdm import tqdm | |
import json | |
import re | |
from typing import List, Optional, Union, Tuple, Any, Callable, Generator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ask me one question at a time so we can develop a thorough, step-by-step spec for this idea. Each question should build on my previous answers, and our end goal is to have a detailed specification I can hand off to a developer. Let’s do this iteratively and dig into every relevant detail. Remember, only one question at a time. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ask me one question at a time so we can develop a thorough, step-by-step spec for this idea. Each question should build on my previous answers, and our end goal is to have a detailed specification I can hand off to a developer. Let’s do this iteratively and dig into every relevant detail. Remember, only one question at a time. | |
Here’s the idea: | |
<IDEA> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import re | |
from typing import List, Dict, Union, Tuple | |
import math | |
from collections import defaultdict | |
def clean_expression(expr: str) -> str: | |
"""Clean up the expression before processing.""" | |
if not expr: | |
return "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create a Python script that: | |
1. Uses Pydantic for a structured output model with fields: | |
- nums: List[int] # The input numbers | |
- target: int # Target number to reach | |
- expression: str # Model's arithmetic expression | |
- valid: bool # Whether expression is valid | |
2. Loads a single sample from "Jiayi-Pan/Countdown-Tasks-3to4-Unique" dataset |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import transformers | |
import torch | |
from unsloth import FastLanguageModel, PatchFastRL, is_bfloat16_supported | |
import re | |
from datasets import load_dataset, Dataset | |
from trl import GRPOConfig, GRPOTrainer | |
from transformers import AutoModelForCausalLM, AutoTokenizer, AutoConfig | |
from peft import get_peft_model_state_dict, PeftConfig, PeftModel | |
import logging |
NewerOlder