Skip to content

Instantly share code, notes, and snippets.

View dhruvilp's full-sized avatar
๐Ÿ’ญ
๐Ÿ‘จโ€๐Ÿ’ป working on something really cool

Dhruvil Patel dhruvilp

๐Ÿ’ญ
๐Ÿ‘จโ€๐Ÿ’ป working on something really cool
View GitHub Profile
@dhruvilp
dhruvilp / Ft.py
Created October 29, 2025 04:09
Oss ft
# train.py
# Run with: accelerate launch --num_processes 4 train.py
# Make sure to have accelerate config set up for DDP, or it will auto.
import os
import torch
from datasets import load_dataset
from peft import LoraConfig, get_peft_model, TaskType
from transformers import (
AutoModelForCausalLM,
@dhruvilp
dhruvilp / README.md
Created October 21, 2025 03:56
docling plain parallel processing

Granite Docling Document Converter

A high-performance, parallel-processing library for converting documents to Markdown, JSON, and DocTags using the Granite Docling model. No FastAPI, Flask, or web frameworks required - pure Python library with sync and async support.

๐Ÿš€ Features

  • No Web Framework Required: Pure Python library - use it directly in your code
  • Parallel Processing: Process large PDFs with multiple workers for maximum speed
  • Async Support: Full async/await support for non-blocking operations
  • Multiple Output Formats: Convert to Markdown, JSON, DocTags
@dhruvilp
dhruvilp / README.md
Last active October 25, 2025 01:39
granite-docling-258m inference
[
  {
    "content": "reasoning language: English\n\nYou are an intelligent assistant that can answer customer service queries",
    "role": "system",
    "thinking": null
  },
  {
    "content": "Can you provide me with a list of the top-rated series currently on Netflix?",
 "role": "user",
@dhruvilp
dhruvilp / quant-gpt-oss.py
Last active October 15, 2025 20:44
quant gpt oss local
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
import time
model_path = './gpt-oss-model-local'
quantization_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_use_double_quant=True,
@dhruvilp
dhruvilp / data-gen-script-gen-qa.py
Last active October 13, 2025 03:22
gpt-oss-20b-ft-lora-sample-code
import json
import pandas as pd
from langchain.text_splitter import RecursiveCharacterTextSplitter
from openai import OpenAI
import os
from typing import List, Dict
import random
class SyntheticDataGenerator:
def __init__(self, api_key: str = None, model: str = "gpt-4"):
@dhruvilp
dhruvilp / webpageloader.py
Created October 6, 2025 21:06
crawl4ai web page loader
import asyncio
import json
import os
from base64 import b64decode
from typing import List, Dict, Optional, Any
from pydantic import BaseModel, Field
from crawl4ai import (
AsyncWebCrawler, BrowserConfig, CrawlerRunConfig, CacheMode,
JsonCssExtractionStrategy, LLMExtractionStrategy, LLMConfig,
@dhruvilp
dhruvilp / t_to_sb.txt
Created March 25, 2025 03:49
Tomcat to Spring Boot
nference Providers
NEW
Fireworks
Text Generation
Reset
Examples
Input a message to start chatting with deepseek-ai/DeepSeek-V3-0324.
How can I convert an app running on tomcat Catalina 8 server to spring boot app with jdk 17
@dhruvilp
dhruvilp / thinking_tokens.py
Created February 18, 2025 16:01 — forked from zainhas/thinking_tokens.py
Extract ONLY thinking tokens from DeepSeek-R1
from together import Together
client = Together(api_key = TOGETHER_API_KEY)
question = "Which is larger 9.9 or 9.11?"
thought = client.chat.completions.create(
model="deepseek-ai/DeepSeek-R1",
messages=[{"role": "user", "content": question}],
stop = ['</think>']
)
@dhruvilp
dhruvilp / aimlapi-starter.py
Created November 18, 2024 15:14
AIML API Code Snippet
# pip install openai
import os
from openai import OpenAI
aiml_api_key ='<YOUR_AIML_API_KEY>'
client = OpenAI(
api_key=aiml_api_key,
base_url="https://api.aimlapi.com",
)
We can't make this file beautiful and searchable because it's too large.
"age";"job";"marital";"education";"default";"housing";"loan";"contact";"month";"day_of_week";"duration";"campaign";"pdays";"previous";"poutcome";"emp.var.rate";"cons.price.idx";"cons.conf.idx";"euribor3m";"nr.employed";"y"
56;"housemaid";"married";"basic.4y";"no";"no";"no";"telephone";"may";"mon";261;1;999;0;"nonexistent";1.1;93.994;-36.4;4.857;5191;"no"
57;"services";"married";"high.school";"unknown";"no";"no";"telephone";"may";"mon";149;1;999;0;"nonexistent";1.1;93.994;-36.4;4.857;5191;"no"
37;"services";"married";"high.school";"no";"yes";"no";"telephone";"may";"mon";226;1;999;0;"nonexistent";1.1;93.994;-36.4;4.857;5191;"no"
40;"admin.";"married";"basic.6y";"no";"no";"no";"telephone";"may";"mon";151;1;999;0;"nonexistent";1.1;93.994;-36.4;4.857;5191;"no"
56;"services";"married";"high.school";"no";"no";"yes";"telephone";"may";"mon";307;1;999;0;"nonexistent";1.1;93.994;-36.4;4.857;5191;"no"
45;"services";"married";"basic.9y";"unknown";"no";"no";"telephone";"may";"mon";198;1;999;0;"nonexistent";1.1;93.994;-36.4