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
| # train_grpo.py | |
| import re | |
| import torch | |
| from datasets import load_dataset, Dataset | |
| from transformers import AutoTokenizer, AutoModelForCausalLM | |
| from peft import LoraConfig | |
| from trl import GRPOConfig, GRPOTrainer | |
| # Load and prep dataset |
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 tensorflow as tf | |
| # 1000 * 1.07 ** X = 2000 | |
| # p * r ** X = y | |
| p = tf.constant(1000.) | |
| r = tf.constant(1.07) | |
| X = tf.Variable(1., constraint=tf.keras.constraints.non_neg()) | |
| y = tf.constnat(2000.) | |
| lhs = p * tf.pow(r, X) |
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
| In [1]: import spacy | |
| In [2]: nlp = spacy.load('en_core_web_md') | |
| --------------------------------------------------------------------------- | |
| OSError Traceback (most recent call last) | |
| <ipython-input-2-614d6de0ab0f> in <module> | |
| ----> 1 nlp = spacy.load('en_core_web_md') | |
| /usr/local/lib/python3.7/site-packages/spacy/__init__.py in load(name, **overrides) | |
| 19 if depr_path not in (True, False, None): |
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 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
| class FSM(object): | |
| def __init__(self, pattern, mappings=None): | |
| self.pattern = pattern | |
| if mappings is not None: | |
| print(repr(mappings)) | |
| self.mappings = {v: k for k, v in mappings.items() if not callable(v)} | |
| self.adv_mappings = {v: k for k, v in mappings.items() if callable(v)} | |
| else: | |
| self.mappings, self.adv_mappings = {}, {} | |
| def where(self, **mappings): |
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
| from ipyparallel import Client, require | |
| from IPython.core.magic import Magics, magics_class, cell_magic, line_magic | |
| RC = Client() | |
| @contextmanager | |
| def apply_parallel(block=False, remote_client=RC): | |
| view = remote_client.load_balanced_view() | |
| async_results = [] |
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
| # Generated by the protocol buffer compiler. DO NOT EDIT! | |
| # source: im.proto | |
| import sys | |
| _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) | |
| from google.protobuf.internal import enum_type_wrapper | |
| from google.protobuf import descriptor as _descriptor | |
| from google.protobuf import message as _message | |
| from google.protobuf import reflection as _reflection | |
| from google.protobuf import symbol_database as _symbol_database |
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
| syntax = "proto3"; | |
| package im; | |
| enum Client { | |
| CLIENT_UNKNOWN = 0; | |
| CLIENT_NATIVE_APP = 1; | |
| CLIENT_WEB_APP = 2; | |
| CLIENT_API = 3; | |
| } |
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
| function msg() { | |
| echo -n '{"description":"","public":"false","files":{"file1.txt":{"content":"' | |
| awk '{gsub(/"/,"\\\""); printf "%s\\n",$0}' "$1" | |
| echo '"}}' | |
| } | |
| [ "$#" -ne 1 ] && echo "Syntax: gist.sh filename" && exit 1 | |
| [ ! -r "$1" ] && echo "Error: unable to read $1" && exit 2 | |
| msg "$1" | curl -v -d '@-' https://api.github.com/gists |
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
| def trace(frame, event, arg): | |
| relevant_fname_substr = '' # populate with filename substring | |
| try: | |
| if relevant_fname_substr not in frame.f_code.co_filename: | |
| return | |
| print("{0.f_code.co_filename}: {0.f_lineno}".format(frame)) | |
| except Exception: | |
| pass | |
| from contextlib import contextmanager | |
| @contextmanager |
NewerOlder