repo_full_name stringlengths 6 93 | repo_url stringlengths 25 112 | repo_api_url stringclasses 28
values | owner stringclasses 28
values | repo_name stringclasses 28
values | description stringclasses 28
values | stars int64 617 98.8k | forks int64 31 355 ⌀ | watchers int64 990 999 ⌀ | license stringclasses 2
values | default_branch stringclasses 2
values | repo_created_at timestamp[s]date 2012-07-24 23:12:50 2025-06-16 08:07:28 ⌀ | repo_updated_at timestamp[s]date 2026-02-23 15:23:15 2026-05-03 18:52:12 ⌀ | repo_topics listlengths 0 13 ⌀ | repo_languages unknown | is_fork bool 1
class | open_issues int64 3 104 ⌀ | file_path stringlengths 3 208 | file_name stringclasses 509
values | file_extension stringclasses 1
value | file_size_bytes int64 101 84k ⌀ | file_url stringclasses 627
values | file_raw_url stringclasses 627
values | file_sha stringclasses 624
values | language stringclasses 8
values | parsed_at stringdate 2026-05-04 01:12:36 2026-05-04 19:41:55 | text stringlengths 100 102k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
jazzband/tablib | https://github.com/jazzband/tablib | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | src/tablib/formats/_latex.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:28.790715 | """Tablib - LaTeX table export support.
Generates a LaTeX booktabs-style table from the dataset.
"""
import re
class LATEXFormat:
title = 'latex'
extensions = ('tex',)
TABLE_TEMPLATE = """\
%% Note: add \\usepackage{booktabs} to your preamble
%%
\\begin{table}[!htbp]
\\centering
%(CAPTION)s
\\b... |
jazzband/tablib | https://github.com/jazzband/tablib | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | src/tablib/formats/_ods.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:28.830933 | """ Tablib - ODF Support.
"""
import datetime as dt
import numbers
from io import BytesIO
from odf import number, opendocument, style, table, text
import tablib
bold = style.Style(name="bold", family="paragraph")
bold.addElement(style.TextProperties(
fontweight="bold",
fontweightasian="bold",
fontweight... |
jazzband/tablib | https://github.com/jazzband/tablib | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | src/tablib/formats/_tsv.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:28.837221 | """ Tablib - TSV (Tab Separated Values) Support.
"""
from ._csv import CSVFormat
class TSVFormat(CSVFormat):
title = 'tsv'
extensions = ('tsv',)
DEFAULT_DELIMITER = '\t'
|
jazzband/tablib | https://github.com/jazzband/tablib | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | src/tablib/formats/_rst.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:28.837771 | """ Tablib - reStructuredText Support
"""
from itertools import zip_longest
from statistics import median
from textwrap import TextWrapper
JUSTIFY_LEFT = 'left'
JUSTIFY_CENTER = 'center'
JUSTIFY_RIGHT = 'right'
JUSTIFY_VALUES = (JUSTIFY_LEFT, JUSTIFY_CENTER, JUSTIFY_RIGHT)
def to_str(value):
if isinstance(value... |
jazzband/tablib | https://github.com/jazzband/tablib | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | src/tablib/formats/_xlsx.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:28.856955 | """ Tablib - XLSX Support.
"""
import re
from io import BytesIO
from openpyxl.reader.excel import ExcelReader, load_workbook
from openpyxl.styles import Alignment, Font
from openpyxl.utils import get_column_letter
from openpyxl.workbook import Workbook
import tablib
INVALID_TITLE_REGEX = re.compile(r'[\\*?:/\[\]]')
... |
jazzband/tablib | https://github.com/jazzband/tablib | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | src/tablib/formats/_sql.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:28.865637 | """Tablib - SQL INSERT Export Support."""
import datetime
import decimal
from ..exceptions import UnsupportedFormat
class SQLFormat:
"""Export Dataset rows as SQL INSERT statements."""
title = 'sql'
extensions = ('sql',)
@staticmethod
def _render_literal(value):
"""Render a Python value ... |
jazzband/tablib | https://github.com/jazzband/tablib | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | src/tablib/utils.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:28.877110 | from io import BytesIO, StringIO
def normalize_input(stream):
"""
Accept either a str/bytes stream or a file-like object and always return a
file-like object.
"""
if isinstance(stream, str):
return StringIO(stream, newline='')
elif isinstance(stream, bytes):
return BytesIO(stre... |
jazzband/tablib | https://github.com/jazzband/tablib | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | src/tablib/formats/_yaml.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:28.877665 | """ Tablib - YAML Support.
"""
import yaml
import tablib
class YAMLFormat:
title = 'yaml'
extensions = ('yaml', 'yml')
@classmethod
def export_set(cls, dataset):
"""Returns YAML representation of Dataset."""
return yaml.safe_dump(
dataset._package(), default_flow_style=N... |
jazzband/tablib | https://github.com/jazzband/tablib | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | src/tablib/formats/_xls.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:28.879983 | """ Tablib - XLS Support.
"""
import datetime
import re
from io import BytesIO
import xlrd
import xlwt
from xlrd.xldate import xldate_as_datetime
import tablib
# special styles
wrap = xlwt.easyxf("alignment: wrap on")
bold = xlwt.easyxf("font: bold on")
datetime_style = xlwt.easyxf(num_format_str='M/D/YY h:mm')
date... |
jazzband/tablib | https://github.com/jazzband/tablib | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | tests/test_tablib.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:29.388898 | #!/usr/bin/env python
"""Tests for Tablib."""
import datetime as dt
import doctest
import json
import pickle
import re
import tempfile
import unittest
from decimal import Decimal
from io import BytesIO, StringIO
from pathlib import Path
from uuid import uuid4
import xlrd
from odf import opendocument, table
from openp... |
jazzband/tablib | https://github.com/jazzband/tablib | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | tests/test_tablib_dbfpy_packages_fields.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:29.401580 | #!/usr/bin/env python
"""Tests for tablib._vendor.dbfpy."""
import unittest
from tablib._vendor.dbfpy import fields
class DbfFieldDefTestCompareCase(unittest.TestCase):
"""dbfpy.fields.DbfFieldDef comparison test cases, via child classes."""
def setUp(self) -> None:
self.length = 10
self.a ... |
jazzband/tablib | https://github.com/jazzband/tablib | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | tests/test_tablib_dbfpy_packages_utils.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:29.479453 | #!/usr/bin/env python
"""Tests for tablib._vendor.dbfpy."""
import datetime as dt
import unittest
from tablib._vendor.dbfpy import utils
class UtilsUnzfillTestCase(unittest.TestCase):
"""dbfpy.utils.unzfill test cases."""
def test_unzfill_with_nul(self):
# Arrange
text = b"abc\0xyz"
... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/engines/china_a.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:32.759784 | """A-share (China mainland) backtest engine.
Market rules:
- T+1: cannot sell shares bought today
- No short selling for retail investors
- Price limits: ±10% main board, ±20% ChiNext/STAR, ±5% ST
- Minimum lot: 100 shares (odd lots can only be sold, not bought)
- Commission: ¥5 minimum, 0.025% bilateral
-... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/engines/_market_hooks.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:32.775154 | """Extracted per-bar market hooks as pure functions.
Both the original engines (CryptoEngine, ForexEngine) and CompositeEngine
call these same functions. Zero duplication — one source of truth.
"""
from __future__ import annotations
from typing import Dict
import pandas as pd
from backtest.models import Position
... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/engines/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:32.796496 | """Backtest engines.
Wave 1 (v1):
- BaseEngine: ABC for bar-by-bar execution with market rules
- ChinaAEngine: A-share (T+1, no short, price limits)
- GlobalEquityEngine: US / HK equities
- CryptoEngine: Crypto perpetuals (funding fees, liquidation)
- options_portfolio: European/American options (Black-Schol... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/api_server.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:33.580528 | #!/usr/bin/env python3
"""Vibe-Trading API Server - RESTful API for finance research and backtesting.
V5: ReAct Agent + async /run + CORS env + SSE tool events.
"""
from __future__ import annotations
import asyncio
import hmac
import ipaddress
import json
import os
import signal
import time
import csv
import uuid
fr... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/engines/crypto.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:33.637661 | """Crypto perpetual-contract backtest engine.
Market rules:
- 24/7 trading, no restrictions on direction
- Maker/Taker fee separation
- Funding fee settlement every 8 hours (00:00/08:00/16:00 UTC)
- Forced liquidation when maintenance margin ratio <= 100%
- Fractional position sizes allowed
"""
from __futur... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/engines/china_futures.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:33.988712 | """China futures backtest engine.
Market rules (exchange-level, CFFEX / SHFE / DCE / ZCE / INE / GFEX):
- T+0: can open and close same day (intraday trading allowed)
- Margin trading: 5%~15% by product (exchange-set minimum)
- Price limits: stock-index +-10%, bonds +-2%, commodities +-3%~8%
- Commission: per-l... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/benchmark.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:34.066101 | """Benchmark ticker resolution and fetch for backtest comparison.
Provides a lightweight, zero-dependency way to fetch benchmark reference
data given a set of strategy codes and a data source.
"""
from __future__ import annotations
from dataclasses import dataclass
from typing import Optional
import pandas as pd
f... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/correlation.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:34.110324 | """Cross-asset correlation matrix computation.
Computes pairwise Pearson or Spearman correlation of daily returns
over a configurable lookback window. Used by the /correlation API endpoint.
"""
from __future__ import annotations
from typing import Dict, Literal
import pandas as pd
import numpy as np
from scipy.stat... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/engines/composite.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:34.167656 | """Composite cross-market backtest engine.
Manages a shared capital pool across multiple market engines.
Sub-engines are used as stateless "rule books" for market-specific
calculations (commission, slippage, lot rounding, etc.).
All state (capital, positions, trades) lives in CompositeEngine.
"""
from __future__ impo... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/engines/global_equity.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:34.183515 | """Global equity (US / HK) backtest engine.
Market rules:
US:
- T+0, long/short allowed
- Zero commission (retail brokers)
- Fractional shares supported (round to 0.01)
- Low slippage (high liquidity)
HK:
- T+0, long/short allowed
- Stamp tax 0.1% bilateral + levies
- Lot-size rounding ... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/engines/global_futures.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:34.254206 | """Global futures backtest engine (CME / ICE / Eurex).
Market rules:
- Nearly 24x5 (CME Globex: Sun 17:00 - Fri 16:00 CT, daily pause 16:00-17:00)
- Margin: initial + maintenance (exchange-set per contract)
- Limit up/down: dynamic for equity index, fixed for commodities
- Contract multiplier: per-product (ES=... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/engines/base.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:34.311682 | """Base backtest engine with shared bar-by-bar execution loop.
All market engines inherit from BaseEngine and override market-rule methods.
The shared run_backtest() handles: data loading → signal generation →
pre-compute target weights (with optimizer) → bar-by-bar execution with
market rule enforcement → metrics → a... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/engines/options_portfolio.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:34.525323 | """Options portfolio backtest engine (v2).
Supports European and American options via Black-Scholes model with
IV smile approximation. Synthesises theoretical option prices from
underlying prices; supports multi-leg strategies.
v2 enhancements over v1:
- American option support (early exercise heuristic for calls ... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/loaders/akshare_loader.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:34.626798 | """AKShare loader: free, no-auth data for A-shares, US, HK, futures, forex, macro.
AKShare (https://github.com/akfamily/akshare) is a completely free financial
data aggregator covering Chinese and global markets. No API token required.
"""
from __future__ import annotations
import logging
from typing import Dict, L... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/loaders/base.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:34.681431 | """DataLoader Protocol and shared exceptions for all data source loaders."""
from __future__ import annotations
from typing import Protocol, runtime_checkable
import pandas as pd
class NoAvailableSourceError(Exception):
"""Raised when no data source is available for a given market."""
def validate_date_range... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/loaders/ccxt_loader.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:34.703414 | """CCXT loader: unified crypto exchange data (100+ exchanges).
Uses the CCXT library to fetch OHLCV candles from any supported exchange.
Defaults to Binance; configurable via CCXT_EXCHANGE env var.
No API key required for public market data.
"""
from __future__ import annotations
import logging
import os
from typing... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/loaders/futu.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:34.745518 | """Futu OpenAPI-backed loader for HK and China A-share OHLCV data."""
from __future__ import annotations
import logging
import os
from typing import Dict, List, Optional
import pandas as pd
from backtest.loaders.base import NoAvailableSourceError, validate_date_range
from backtest.loaders.registry import register
... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/loaders/okx.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:34.855878 | """OKX spot candle loader (crypto).
Uses OKX V5 public REST API (no auth).
Supports 1m/5m/15m/30m/1H/4H/1D.
Up to 300 bars per request; paginates with ``after`` for longer history.
"""
from typing import Dict, List, Optional
import pandas as pd
import requests
from backtest.loaders.base import validate_date_range
f... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/loaders/registry.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:34.929517 | """Loader registry with market-level fallback chains.
Loaders self-register via the ``@register`` decorator when their module is
first imported. The ``_ensure_registered()`` helper lazily imports every
known loader module so that callers of ``resolve_loader`` /
``get_loader_cls_with_fallback`` never see an empty regi... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/loaders/tushare.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:35.092858 | """Tushare loader for A-share daily and intraday bars plus optional fundamentals.
Supports ``interval``: 1D (default) / 1m / 5m / 15m / 30m / 1H.
Minute data uses ``pro.stk_mins()`` (Tushare points >= 2000).
"""
import os
from typing import Dict, List, Optional
import pandas as pd
from backtest.loaders.base import ... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/loaders/yfinance_loader.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:35.097504 | """yfinance-backed loader for HK/US equity OHLCV data."""
from __future__ import annotations
from collections import defaultdict
from typing import Dict, List, Optional, Union
import pandas as pd
import yfinance as yf
from backtest.loaders.base import validate_date_range
from backtest.loaders.registry import regist... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/metrics.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:35.217049 | """Shared backtest metrics, extracted from daily_portfolio.py for reuse.
Provides annualisation helpers, trade statistics, and full metric calculation.
"""
from __future__ import annotations
from typing import Any, Dict, List, Optional
import numpy as np
import pandas as pd
from backtest.models import TradeRecord
... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/models.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:35.230489 | """Shared data models for backtest engines.
Immutable dataclasses for positions, trades, and equity snapshots.
"""
from __future__ import annotations
from dataclasses import dataclass
import pandas as pd
@dataclass(frozen=True)
class Position:
"""An open position in a single instrument.
Args:
sym... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/optimizers/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:35.307405 | """Portfolio optimizer package.
Provides four weighting schemes:
- equal_volatility: inverse-volatility weights
- risk_parity: equal risk contribution (Spinu-style)
- mean_variance: max Sharpe via scipy
- max_diversification: maximize diversification ratio
Select via ``optimizer`` in ``config.json``; default is off (... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/optimizers/base.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:35.383559 | """Shared base class for portfolio optimizers.
Handles preprocessing, rolling covariance windows, and weight normalization;
subclasses implement ``_calc_weights``.
"""
from abc import ABC, abstractmethod
from typing import Dict, Any, List
import numpy as np
import pandas as pd
class BaseOptimizer(ABC):
"""Abst... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/optimizers/equal_volatility.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:35.420231 | """Equal-volatility (inverse-volatility) weighting.
Higher weight on lower-volatility names so each asset contributes similar vol.
"""
from typing import Any, Dict, List
import numpy as np
import pandas as pd
from backtest.optimizers.base import BaseOptimizer
class EqualVolatilityOptimizer(BaseOptimizer):
"""... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/optimizers/max_diversification.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:35.496222 | """Maximum diversification ratio: maximize (w' sigma) / sqrt(w' Sigma w).
``sigma`` is the vector of asset volatilities; ``Sigma`` is the covariance matrix.
Higher DR means more diversification per unit of risk.
"""
from typing import Any, Dict
import numpy as np
import pandas as pd
from backtest.optimizers.base im... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/optimizers/risk_parity.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:35.654534 | """Risk parity: equalize marginal risk contributions.
Iterative refinement so w_i * MRC_i is approximately equal across assets.
"""
from typing import Any, Dict
import numpy as np
import pandas as pd
from backtest.optimizers.base import BaseOptimizer
class RiskParityOptimizer(BaseOptimizer):
"""Spinu (2013)-s... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/optimizers/mean_variance.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:35.681959 | """Mean-variance (max Sharpe) optimizer: max (w'mu - r_f) / sqrt(w'Sigma w), w>=0, sum(w)=1."""
from typing import Any, Dict, List
import numpy as np
import pandas as pd
from backtest.optimizers.base import BaseOptimizer
class MeanVarianceOptimizer(BaseOptimizer):
"""Maximize Sharpe ratio subject to long-only ... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/runner.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:35.815782 | """Fixed backtest entrypoint: read config.json, select loader by source, import signal_engine, run engine.
Supports ``source="auto"`` to route codes to loaders by symbol format.
Supports ``interval`` for bar size (1m/5m/15m/30m/1H/4H/1D, default 1D).
Supports ``engine`` for backtest engine (daily/options, default dail... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/validation.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:35.828429 | """Statistical validation for backtest results.
Three independent tools:
- Monte Carlo permutation test: is the strategy significantly better than random?
- Bootstrap Sharpe CI: how stable is the risk-adjusted return?
- Walk-Forward analysis: is performance consistent across time windows?
Usage: called automati... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/cli.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:35.900498 | #!/usr/bin/env python3
"""Vibe-Trading CLI — natural-language finance research & backtesting.
Usage:
vibe-trading Interactive mode (default)
vibe-trading -p "Backtest AAPL MACD" Single run
vibe-trading serve --port 8899 Start API server
vibe-trading chat ... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/mcp_server.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:35.975835 | #!/usr/bin/env python3
"""Vibe-Trading MCP Server — expose 22 finance research tools to any MCP client.
Works with OpenClaw, Claude Desktop, Cursor, and any MCP-compatible client.
Zero API key required for HK/US/crypto markets (yfinance, OKX, AKShare are free).
Usage:
python mcp_server.py # std... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/src/agent/__init__.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:36.095626 | """Agent core module: ReAct AgentLoop, tool registry, context, workspace memory, skills."""
from src.agent.loop import AgentLoop
from src.agent.memory import WorkspaceMemory
from src.agent.skills import SkillsLoader
from src.agent.tools import BaseTool, ToolRegistry
__all__ = ["AgentLoop", "WorkspaceMemory", "SkillsL... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/src/agent/frontmatter.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:36.226698 | """Shared YAML-like frontmatter parser for skills and memory files."""
from __future__ import annotations
import re
from typing import Any, Dict
def parse_frontmatter(text: str) -> tuple[Dict[str, Any], str]:
"""Parse YAML-like frontmatter and body from a markdown file.
Supports string, list (``[a, b]``), ... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/src/agent/context.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:36.256880 | """ContextBuilder: builds LLM message context for the ReAct AgentLoop."""
from __future__ import annotations
import json
import logging
from datetime import datetime
from typing import TYPE_CHECKING, Any, Dict, List, Optional
from src.agent.memory import WorkspaceMemory
from src.agent.skills import SkillsLoader
from... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/src/agent/loop.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:36.387660 | """AgentLoop: ReAct core loop.
Five-layer context management:
Layer 1 (microcompact) — silently prunes old tool results each iteration
Layer 2 (context_collapse) — folds long text blocks without LLM call (zero cost)
Layer 3 (auto_compact) — LLM structured summary with token-budget tail protection
Layer... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/src/agent/memory.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:36.473224 | """Workspace memory: shared state across tool calls within a single run.
Lightweight runtime state — survives within one AgentLoop.run() invocation only.
Cross-session persistence is handled by src.memory.persistent.PersistentMemory.
"""
from __future__ import annotations
from dataclasses import dataclass, field
fro... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/src/agent/skills.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:36.483929 | """SkillsLoader: loads scenario guides from the skills/ directory.
Uses progressive disclosure:
- System prompt only injects one-line summaries (get_descriptions).
- Full docs loaded on demand (get_content, called by the load_skill tool).
"""
from __future__ import annotations
import re
from dataclasses import datac... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/src/agent/tools.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:36.528561 | """BaseTool + ToolRegistry: tool infrastructure."""
from __future__ import annotations
import json
import logging
from abc import ABC, abstractmethod
logger = logging.getLogger(__name__)
from typing import Any, Dict, List, Optional
class BaseTool(ABC):
"""Tool base class.
Attributes:
name: Unique ... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/src/agent/trace.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:36.586286 | """TraceWriter: crash-safe JSONL trace writer.
One JSON record per line; append + flush guarantees no data loss on crash.
"""
from __future__ import annotations
import json
import time
from pathlib import Path
from typing import Any, Dict, List, Optional
class TraceWriter:
"""JSONL trace writer, one record per... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/src/core/runner.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:36.803342 | """Runner module for executing generated backtest code and collecting artifacts."""
from __future__ import annotations
import os
import subprocess
import sys
import time
from dataclasses import dataclass
from pathlib import Path
from typing import Any, Dict, Optional
from rich.console import Console
console = Cons... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/src/core/state.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:36.803868 | """Run state persistence: creates run directories and records status."""
from __future__ import annotations
import json
import uuid
from datetime import datetime
from pathlib import Path
from typing import Any, Dict
class RunStateStore:
"""Run state store: manages run directories and their lifecycle status."""
... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/engines/futures_base.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:38.628856 | """Base class for all futures engines.
Adds contract-multiplier awareness on top of BaseEngine.
Only futures engines inherit from this; stocks/crypto/forex use BaseEngine directly.
The multiplier affects:
- PnL: direction * size * multiplier * (exit - entry)
- Margin: size * price * multiplier / leverage
- Posi... |
HKUDS/Vibe-Trading | https://github.com/HKUDS/Vibe-Trading | null | null | null | null | 4,750 | null | null | mit | null | null | null | null | null | null | null | agent/backtest/engines/forex.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:38.833367 | """Forex (FX spot / CFD) backtest engine.
Market rules:
- 24x5 (Mon Sydney open to Fri NYC close)
- Spread replaces explicit commission (bid-ask)
- Leverage: 50:1 to 500:1 (configurable)
- Standard lot = 100,000 units of base currency
- Swap (overnight rollover interest) at daily close
- No price limits, n... |
yanshengjia/ml-road | https://github.com/yanshengjia/ml-road | null | null | null | null | 4,746 | null | null | mit | null | null | null | null | null | null | null | projects/chinese-character-recognition/chinese_character_recognition_bn.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:41.394553 | # with batch norm
import os
import random
import tensorflow.contrib.slim as slim
import time
import logging
import numpy as np
import tensorflow as tf
import pickle
from PIL import Image
from tensorflow.python.ops import control_flow_ops
os.environ['CUDA_VISIBLE_DEVICES']='1'
logger = logging.getLogge... |
yanshengjia/ml-road | https://github.com/yanshengjia/ml-road | null | null | null | null | 4,746 | null | null | mit | null | null | null | null | null | null | null | projects/mnist-handwritten-digit-recognition/mnist_softmax.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:41.441862 | # !/usr/bin/python
# -*- coding:utf-8 -*-
# @author: Shengjia Yan
# @date: 2018-01-09 Tuesday
# @email: i@yanshengjia.com
# Copyright 2018 Shengjia Yan. All Rights Reserved.
"""A very simple MNIST classifier.
See extensive documentation at
https://www.tensorflow.org/get_started/mnist/beginners
"""
from __future__ i... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/hh/sft_hh.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:43.839846 | import json
import sys
from datasets import load_dataset
from ppo_hh import create_reward_fn
import trlx
from trlx.data.default_configs import (
ModelConfig,
OptimizerConfig,
SchedulerConfig,
SFTConfig,
TokenizerConfig,
TrainConfig,
TRLConfig,
)
default_config = TRLConfig(
train=Train... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | docs/source/conf.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:43.849237 | # Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If ex... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/hh/ppo_hh.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:43.851545 | import json
import math
import os
import sys
from itertools import islice
import numpy as np
import torch
import tritonclient.grpc as client_util
from datasets import load_dataset
from huggingface_hub import snapshot_download
from torch import nn
from transformers import AutoModelForCausalLM, AutoTokenizer
from triton... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/hh/ilql_hh.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:43.854150 | import json
import os
import sys
from itertools import islice
from datasets import load_dataset
from ppo_hh import create_reward_fn
import trlx
from trlx.data.default_configs import (
ILQLConfig,
ModelConfig,
OptimizerConfig,
SchedulerConfig,
TokenizerConfig,
TrainConfig,
TRLConfig,
)
def... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/experiments/grounded_program_synthesis/train_trlx.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:43.855341 | import json
import logging
import pathlib
import yaml
from lang import Interpreter
import trlx
from trlx.data.configs import TRLConfig
logger = logging.getLogger(__name__)
class DSLDataset:
def __init__(self):
with open("dataset/train.json", "r") as f:
self.train_data = json.load(f)
... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/experiments/grounded_program_synthesis/lang.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:43.890207 | # flake8: noqa
import copy
import json
import random
from pathlib import Path
from pprint import pprint
from tqdm import tqdm
from transformers import AutoTokenizer
def init_random_input(len_range: int = 5, value_gen=5) -> list:
len_gen = random.randint(2, len_range + 1)
value_range = list(range(-value_gen, ... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/alpaca/sft_alpaca.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:44.439926 | import json
import os
from argparse import ArgumentParser
from typing import Dict, List
from datasets import load_dataset
from transformers import pipeline
import trlx
from trlx.data.default_configs import TRLConfig, default_sft_config
def get_positive_score(scores):
"Extract value associated with a positive se... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/architext.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:44.570064 | # Toy example of optimizing textual interior designs to output the least number of rooms
# Also see https://architext.design/
import trlx
from trlx.data.default_configs import default_ppo_config
def reward_fn(samples, **kwargs):
"Gives a negative count of rooms for each sample"
return [-sample.count(":") for ... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/ilql_sentiments_t5.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:44.929070 | import os
from typing import Dict, List
import numpy as np
from datasets import load_dataset
from transformers import AutoTokenizer, pipeline
import trlx
from trlx.data.configs import (
ModelConfig,
OptimizerConfig,
SchedulerConfig,
TokenizerConfig,
TrainConfig,
TRLConfig,
)
from trlx.models.m... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/llama_nemo/nemo_llama2_ppo_sentiments.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:44.932576 | # Generates positive movie reviews by tuning a pretrained model on IMDB dataset
# with a sentiment reward function
import json
import os
import sys
from typing import List
from datasets import load_dataset
from transformers import DistilBertForSequenceClassification, pipeline
import trlx
from trlx.data.default_config... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/llama_nemo/convert_llama_to_nemo.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:44.935695 | # flake8: noqa
import os
from pathlib import Path
import torch
from omegaconf.omegaconf import OmegaConf
from transformers import AutoModelForCausalLM
def main(args): # noqa: C901
print("Loading model...")
model = AutoModelForCausalLM.from_pretrained(args.model_path, torch_dtype=torch.bfloat16)
print("... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/ilql_sentiments.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:44.937064 | import json
import os
import sys
from typing import Dict, List
from datasets import load_dataset
from transformers import pipeline
import trlx
from trlx.data.default_configs import TRLConfig, default_ilql_config
def get_positive_score(scores):
"Extract value associated with a positive sentiment from pipeline's ... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/hh/to_triton.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:44.938277 | import argparse
import os
from string import Template
import torch
from huggingface_hub import snapshot_download
from torch import nn
from transformers import AutoModelForCausalLM, AutoTokenizer
parser = argparse.ArgumentParser()
parser.add_argument("--base_model", type=str, required=True, help="Path to HF checkpoin... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/nemo_ilql_sentiments.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:44.967068 | from typing import Dict, List
from datasets import load_dataset
from transformers import pipeline
import trlx
from trlx.data.default_configs import default_ilql_config
def get_positive_score(scores):
"Extract value associated with a positive sentiment from pipeline's output"
return dict(map(lambda x: tuple(... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/nemo_ilql_inference.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:44.970010 | import os.path
import sys
from glob import glob
from nemo.collections.nlp.modules.common.megatron.megatron_init import (
fake_initialize_model_parallel,
)
from nemo.utils.app_state import AppState
from nemo.utils.model_utils import inject_model_parallel_rank
from omegaconf.omegaconf import OmegaConf
from trlx.dat... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/nemo_ppo_inference.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:45.039691 | import os.path
import sys
from glob import glob
from omegaconf.omegaconf import OmegaConf
from trlx.data.default_configs import default_ppo_config
from trlx.trainer.nemo_ppo_trainer import PPOGPT, megatron_trainer
default_config = default_ppo_config()
trl_config = default_config.evolve(
train=dict(
defa... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/nemo_ppo_sentiments.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:45.041311 | # Generates positive movie reviews by tuning a pretrained model on IMDB dataset
# with a sentiment reward function
import json
import os
import sys
from typing import List
from datasets import load_dataset
from transformers import DistilBertForSequenceClassification, pipeline
import trlx
from trlx.data.default_config... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/nemo_sft_sentiments.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:45.210571 | import os
from typing import Dict, List
from datasets import load_dataset
from transformers import pipeline
import trlx
from trlx.data.default_configs import (
TRLConfig,
default_nemo_1_3b_config,
default_nemo_20b_config,
default_sft_config,
)
def get_positive_score(scores):
"Extract value assoc... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/ppo_sentiments_t5.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:45.811663 | import json
import os
import sys
from typing import Dict, List
import numpy as np
from datasets import load_dataset
from transformers import AutoTokenizer, pipeline
import trlx
from trlx.data.configs import (
ModelConfig,
OptimizerConfig,
SchedulerConfig,
TokenizerConfig,
TrainConfig,
TRLConfi... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/ppo_sentiments_llama.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:45.813251 | # Generates positive movie reviews by tuning a pretrained model on IMDB dataset
# with a sentiment reward function
import json
import os
import sys
from typing import List
import torch
from datasets import load_dataset
from transformers import pipeline
import trlx
from trlx.data.default_configs import (
ModelConf... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/ppo_translation_t5.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:45.814457 | """Example of using PPO to train a T5 model for translation.
Based on examples/summarize_daily_cnn/t5_summarize_daily_cnn.py"""
import json
import os
import sys
from typing import List
import torch
from datasets import load_dataset
from tqdm import tqdm
from transformers import AutoTokenizer
import trlx
from trlx.da... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/ppo_sentiments_peft.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:45.815883 | # Generates positive movie reviews by tuning a pretrained model on IMDB dataset
# with a sentiment reward function
import json
import os
import sys
from typing import List
import torch
from datasets import load_dataset
from peft import LoraConfig
from peft.utils.config import TaskType
from transformers import pipeline... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/ppo_dense_sentiments.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:46.388258 | # Generates positive movie reviews by tuning a pretrained model on IMDB dataset
# with a sentiment reward function
import json
import os
import sys
from typing import List
import torch
from datasets import load_dataset
from transformers import pipeline
import trlx
from trlx.data.default_configs import TRLConfig, defa... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/ppo_sentiments.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:46.497439 | # Generates positive movie reviews by tuning a pretrained model on IMDB dataset
# with a sentiment reward function
import json
import os
import sys
from typing import List
import torch
from datasets import load_dataset
from transformers import pipeline
import trlx
from trlx.data.default_configs import TRLConfig, defa... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/nemo_vs_ds_chat.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:46.501313 | # Generates positive movie reviews by tuning a pretrained model on IMDB dataset
# with a sentiment reward function
import json
import os
import sys
from math import floor
from typing import List
import torch
from datasets import load_dataset
from transformers import AutoModelForCausalLM, AutoTokenizer
import trlx
fro... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/randomwalks/ilql_randomwalks.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:46.679274 | from transformers import GPT2Config
import trlx
from examples.randomwalks import generate_random_walks
from trlx.data.default_configs import (
ILQLConfig,
ModelConfig,
OptimizerConfig,
SchedulerConfig,
TokenizerConfig,
TrainConfig,
TRLConfig,
)
def main(hparams):
config = TRLConfig.up... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/randomwalks/rft_randomwalks.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:46.835717 | import trlx
from examples.randomwalks import generate_random_walks
from trlx.data.default_configs import (
ModelConfig,
OptimizerConfig,
SchedulerConfig,
TokenizerConfig,
TrainConfig,
TRLConfig,
)
from trlx.trainer.accelerate_rft_trainer import RFTConfig
default_config = TRLConfig(
train=Tr... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/sft_sentiments.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:46.858079 | import json
import os
import sys
from typing import Dict, List
from datasets import load_dataset
from transformers import pipeline
import trlx
from trlx.data.default_configs import TRLConfig, default_sft_config
def get_positive_score(scores):
"Extract value associated with a positive sentiment from pipeline's o... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/rft_sentiments.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:46.878180 | # This script trains a model to output positive reviews
# using rejection finetuning with a sentiment classifier reward function.
import json
import os
import sys
from typing import List
import torch
from datasets import load_dataset
from transformers import pipeline
import trlx
from trlx.data.default_configs import ... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/randomwalks/randomwalks.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:46.887173 | from typing import Callable, Dict, List, Optional, Tuple
import networkx as nx
import numpy as np
import torch
def generate_rand_int_excluding(rng: np.random.RandomState, max: int, exclude: int) -> int:
"""Random integer generator, excluding a specific number
Args:
rng: Numpy random number generator... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/randomwalks/ppo_randomwalks.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:46.896329 | import trlx
from examples.randomwalks import generate_random_walks
from trlx.data.default_configs import (
ModelConfig,
OptimizerConfig,
PPOConfig,
SchedulerConfig,
TokenizerConfig,
TrainConfig,
TRLConfig,
)
default_config = TRLConfig(
train=TrainConfig(
seq_length=10,
e... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/simulacra.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:46.955184 | # Optimize prompts by training on prompts-ratings pairings dataset
# taken from https://github.com/JD-P/simulacra-aesthetic-captions
import os
import sqlite3
from urllib.request import urlretrieve
from accelerate import Accelerator
import trlx
from trlx.data.default_configs import default_ilql_config
url = "https:/... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/summarize_daily_cnn/t5_summarize_daily_cnn.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:47.085985 | from typing import List
from datasets import load_dataset
import trlx
from trlx.data.configs import (
ModelConfig,
OptimizerConfig,
SchedulerConfig,
TokenizerConfig,
TrainConfig,
TRLConfig,
)
from trlx.models.modeling_ppo import PPOConfig
try:
import evaluate
except ImportError:
raise... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/summarize_rlhf/ilql_summarize_t5.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:47.248752 | import os
import torch
from datasets import load_dataset
from reward_model.reward_model import GPTRewardModel
from transformers import AutoTokenizer
import trlx
from trlx.data.default_configs import (
ILQLConfig,
ModelConfig,
OptimizerConfig,
SchedulerConfig,
TokenizerConfig,
TrainConfig,
... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/summarize_rlhf/reward_model/gptj_reward_test.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:47.360732 | import random
import numpy as np
import torch
from datasets import load_dataset
from reward_model import GPTRewardModel
from torch.utils.data import Dataset
from tqdm import tqdm
from transformers import AutoTokenizer
def set_seed(seed_val=42):
random.seed(seed_val)
np.random.seed(seed_val)
torch.manual_... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/summarize_rlhf/reward_model/train_reward_model_gptj.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:47.459286 | import os
import torch
from datasets import load_dataset
from reward_model import GPTRewardModel
from torch.utils.data import Dataset
from tqdm import tqdm
from transformers import AutoTokenizer, Trainer, TrainingArguments
def create_comparison_dataset(path="CarperAI/openai_summarize_comparisons", split="train"):
... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/summarize_rlhf/sft/summarize_dataset.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:47.473427 | import json
import pandas as pd
import torch
from datasets import load_dataset
from torch.utils.data import Dataset
def get_dataset_from_jsonl(jsonl_file, return_summary=True):
# if return_summary is True, return a list of posts with summary concatenated
# if return_summary is False, return a list of posts a... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/summarize_rlhf/sft/train_gptj_summarize.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:47.491329 | import random
import evaluate
import numpy as np
import torch
from summarize_dataset import TLDRDataset
from transformers import (
AutoModelForCausalLM,
AutoTokenizer,
Trainer,
TrainingArguments,
default_data_collator,
)
def set_seed(seed_val=42):
random.seed(seed_val)
np.random.seed(seed... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/summarize_rlhf/reward_model/reward_model.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:47.492030 | import torch
from torch import nn
from transformers import AutoModelForCausalLM, AutoTokenizer
class GPTRewardModel(nn.Module):
def __init__(self, model_path):
super().__init__()
model = AutoModelForCausalLM.from_pretrained(model_path)
self.config = model.config
# `gpt-neo(x)` mode... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/summarize_rlhf/trlx_gptj_text_summarization.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:47.572353 | import os
from typing import List
import torch
from datasets import load_dataset
from reward_model.reward_model import GPTRewardModel
from tqdm import tqdm
from transformers import AutoTokenizer
import trlx
from trlx.data.configs import (
ModelConfig,
OptimizerConfig,
SchedulerConfig,
TokenizerConfig,... |
CarperAI/trlx | https://github.com/CarperAI/trlx | null | null | null | null | 4,745 | null | null | mit | null | null | null | null | null | null | null | examples/summarize_rlhf/trlx_inference_gptj.py | null | null | null | null | null | null | Python | 2026-05-04T01:54:47.666487 | import os
import evaluate
import pandas as pd
import torch
from datasets import load_dataset
from reward_model.reward_model import GPTRewardModel
from tqdm import tqdm
from transformers import AutoModelForCausalLM, AutoTokenizer
def load_model(path):
tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-j-6B... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.