Skip to content

Instantly share code, notes, and snippets.

View JoshuaPurtell's full-sized avatar
💭
Working

Josh Purtell JoshuaPurtell

💭
Working
View GitHub Profile
from pdf2image import convert_from_bytes
from transformers import NougatImageProcessor, NougatTokenizerFast
from transformers.models.vision_encoder_decoder import VisionEncoderDecoderModel
MODEL_ID = "facebook/nougat-small"
def first_page_to_title_and_authors(file):
tokenizer = NougatTokenizerFast.from_pretrained(MODEL_ID)
processor = NougatImageProcessor.from_pretrained(MODEL_ID)
model = VisionEncoderDecoderModel.from_pretrained(MODEL_ID)
file_bytes = file.read()
first_page = convert_from_bytes(file_bytes)[0]
import asyncio
import copy
import hashlib
import json
import os
import random
from dataclasses import dataclass
from typing import Any, Dict, List, Optional
import numpy as np
from pydantic import BaseModel
from typing import List
import anthropic
import instructor
import asyncio
# Patching the Anthropics client with the instructor for enhanced capabilities
anthropic_client = instructor.patch(
create=anthropic.AsyncAnthropic().messages.create,
mode=instructor.Mode.ANTHROPIC_TOOLS
@JoshuaPurtell
JoshuaPurtell / odd_one_out_benchmark.py
Created May 13, 2024 19:42
How does GPT-4O's internal state tracking stack up?
import asyncio
import os
import random
import hashlib
from datetime import datetime
from typing import Dict, List, Type
from dotenv import load_dotenv
from loguru import logger
from pydantic import BaseModel