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
# radiology_eval_trial_code.py | |
# Reproducible trial comparing independent vs combined LLM-as-judge evaluation. | |
import numpy as np | |
import matplotlib.pyplot as plt | |
from math import log2 | |
rng = np.random.default_rng(20250817) | |
N = 200_000 |
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 autogen_core import CancellationToken | |
from pydantic import BaseModel | |
from autogen_core.models import ChatCompletionClient, CreateResult, SystemMessage, UserMessage, AssistantMessage | |
from autogen_core.tools import Tool | |
from llama_cpp import Llama | |
from typing import List, Dict, Any, Literal, Optional, Sequence, Union, AsyncGenerator | |
import json | |
class ComponentModel(BaseModel): | |
provider: 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
# Export To Onnx | |
model.to_onnx(filepath, input_sample, export_params=True) | |
# Export to Torch Script | |
torch.jit.save(model.to_torchscript(), "model.pt") |
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
Trainer(num_gpus=32).predict(millions_of_reviews) |
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
prediction = model.predict("This movie is great!") |
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
# Save Checkpoint | |
trainer.save_checkpoint("text_class_model.pt") | |
# Load Model From Checkpoint | |
model = TextClassifier.load_from_checkpoint("text_class_model.pt") |
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
trainer.test() |
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
trainer = flash.Trainer(gpus=8) | |
trainer = flash.Trainer(gpus=8, num_nodes=32) | |
trainer = flash.Trainer(tpu_cores=1) |
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
trainer = flash.Trainer(max_epochs = 1) | |
trainer.finetune(model, datamodule = datamodule) |
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
model = TextClassifier(num_classes = 2, backbone = 'roberta-base') |
NewerOlder