This file contains hidden or 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 re | |
| import json | |
| import time | |
| import pathlib | |
| from typing import Dict, Any, Tuple | |
| from dotenv import load_dotenv | |
| from jsonschema import validate | |
| from google import genai |
This file contains hidden or 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 pathlib | |
| import os | |
| import re | |
| from jsonschema import validate | |
| from mlx_lm import load | |
| USE_MLX_LM = os.getenv("MLX_BACKEND", "mlx_lm").lower() == "mlx_lm" | |
| if not USE_MLX_LM: | |
| try: | |
| from mlx_genkit import GenerationConfig, generate as gk_generate |
This file contains hidden or 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 re | |
| import json | |
| import time | |
| import pathlib | |
| from typing import Dict, Any, Tuple | |
| from jsonschema import validate | |
| import torch | |
| from transformers import AutoModelForCausalLM, AutoTokenizer |
This file contains hidden or 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
| # general_refsim_env.py | |
| # env = load_environment( | |
| # data_dir="training/data", | |
| # schema={ | |
| # "articles_path": "articles_rows.csv", | |
| # "article_id": "url", | |
| # "article_title": "title", | |
| # "refs_path": "skeets_rows.csv", | |
| # "ref_group_key": "article_url", |
This file contains hidden or 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
| # vf_poker_env.py | |
| # One-file Verifiers Environment for poker action selection. | |
| # Entry point: load_environment(**kwargs) -> vf.Environment | |
| from __future__ import annotations | |
| import json | |
| import math | |
| import random | |
| from typing import Any, Dict, List |
This file contains hidden or 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 geopandas as gpd | |
| import matplotlib.pyplot as plt | |
| import matplotlib.animation as animation | |
| import pandas as pd | |
| country_name_map = { | |
| "Russia": "Russian Federation", | |
| "United Kingdom": "United Kingdom", | |
| "United States": "United States of America", | |
| "Iran": "Iran (Islamic Republic of)", |
This file contains hidden or 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
| # How It Works | |
| # Data Format | |
| # Each “day” has a list of posts; each post is a dict with "prompt" and "answer". | |
| # Instead of an exact textual “answer,” here "answer" is itself a dict containing "likes", "comments", and "quotes". You can add any other engagement metrics you have. | |
| # Reward Calculation | |
| # The interaction_based_reward function simply extracts these integers and calculates a weighted sum as the reward (e.g., likes + 2*comments + 3*quotes). | |
| # You can alter those weights (or the entire reward scheme) however you want. | |
| # GRPO Training |
This file contains hidden or 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
| # --- GRPO to teach poker (using llm-poker) --- | |
| from llm_poker.environment import PokerTable | |
| from llm_poker.llm_player import LLMPlayer | |
| from datasets import Dataset | |
| from trl import GRPOConfig, GRPOTrainer | |
| import re | |
| import json | |
| class GRPOPlayer(LLMPlayer): | |
| """ |
This file contains hidden or 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
| # Updated from voooogel's r1.py sampler. Looks to see if the tokens are of high confidence, and if not forces a resample. | |
| import argparse | |
| import random | |
| import sys | |
| from transformers import AutoModelForCausalLM, AutoTokenizer, DynamicCache | |
| import torch | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("question", type=str) |
This file contains hidden or 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
| # 1. Import Packages | |
| import time | |
| import numpy as np | |
| import pandas as pd | |
| import spacy | |
| from sklearn.feature_extraction.text import CountVectorizer | |
| import os | |
| # 2. AWS Credentials (assuming necessary environment setup for boto3 or S3 access) | |
| os.environ["AWS_ACCESS_KEY_ID"] = "your_aws_access_key_id" |
NewerOlder