Skip to content

Instantly share code, notes, and snippets.

View rajivmehtaflex's full-sized avatar
🚀
smile

Rajiv Mehta rajivmehtaflex

🚀
smile
  • Bacancy Technology
  • Ahmedabad
View GitHub Profile
@willccbb
willccbb / grpo_demo.py
Last active March 16, 2025 02:21
GRPO Llama-1B
# train_grpo.py
#
# See https://github.com/willccbb/verifiers for ongoing developments
#
import re
import torch
from datasets import load_dataset, Dataset
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import LoraConfig
from trl import GRPOConfig, GRPOTrainer
@Maharshi-Pandya
Maharshi-Pandya / contemplative-llms.txt
Last active March 14, 2025 14:57
"Contemplative reasoning" response style for LLMs like Claude and GPT-4o
You are an assistant that engages in extremely thorough, self-questioning reasoning. Your approach mirrors human stream-of-consciousness thinking, characterized by continuous exploration, self-doubt, and iterative analysis.
## Core Principles
1. EXPLORATION OVER CONCLUSION
- Never rush to conclusions
- Keep exploring until a solution emerges naturally from the evidence
- If uncertain, continue reasoning indefinitely
- Question every assumption and inference
You are Grok 2, a curious AI built by xAI. You are intended to answer almost any question, often taking an outside perspective on humanity, and you always strive towards maximum helpfulness!
Remember that you have these general abilities, and many others as well which are not listed here:
You can analyze individual X posts and their links.
You can answer questions about user profiles on X.
You can analyze content uploaded by user including images and pdfs.
You have realtime access to the web and posts on X.
Remember these are some of the abilities that you do NOT have:

🚀 Agents with txtai

We're thrilled to share a preview version of txtai agents. Inspired by the simplicity of frameworks like OpenAI Swarm, txtai agents are built on top of the Transformers Agent framework. This supports all LLMs txtai supports (Hugging Face, llama.cpp, OpenAI + Claude + AWS Bedrock via LiteLLM).

The following example shows how to create an agent with txtai. Agents will be available in the upcoming txtai 8.0 release (available now in the txtai GitHub repo now - follow #804 - feedback welcome).

Install

@tomaarsen
tomaarsen / export_locally.py
Created October 15, 2024 12:30
Export Sentence Transformer models to ONNX (+ optimization, quantization) & OpenVINO
# requires sentence_transformers>=3.2.0
from sentence_transformers import SentenceTransformer, export_optimized_onnx_model, export_dynamic_quantized_onnx_model
# The model to export to ONNX (+ optimize, quantize), OpenVINO
model_id = "mixedbread-ai/mxbai-embed-large-v1"
# Where to save the exported models locally
output_dir = model_id.replace("/", "-")
onnx_model = SentenceTransformer(model_id, backend="onnx", model_kwargs={"export": True})
onnx_model.save_pretrained(output_dir)
@AIAnytime
AIAnytime / reader.py
Created April 15, 2024 18:20
Jina Reader API
import requests
# Base endpoint
base_url = "https://r.jina.ai/"
# Input URL to be appended
input_url = "https://www.stateof.ai/"
# Full URL with the input URL appended after a plus (+) sign
full_url = base_url + input_url
@olafgeibig
olafgeibig / nous-hermes-2-solar.ollama
Created January 3, 2024 09:35
Ollama modelfile for nous-hermes-2-solar-10.7b
FROM ./nous-hermes-2-solar-10.7b.Q5_K_M.gguf
PARAMETER num_ctx 4096
TEMPLATE """<|im_start|>system
{{ .System }}<|im_end|>
<|im_start|>user
{{ .Prompt }}<|im_end|>
<|im_start|>assistant
"""
PARAMETER stop "<|im_start|>"
PARAMETER stop "<|im_end|>"
@danveloper
danveloper / api_adapter.py
Created December 22, 2023 14:16
Translate Llama2-7B-functions output model to OAI JSON spec
from fastapi import FastAPI, Request
import json
import requests
"""
{
"messages": [
{
"content": "you are immensely smart function AI",
"role": "system"

Here is how to use @MistralAI experimental Mistral-medium using @simonw's https://llm.datasette.io CLI:

  1. Edit the OpenAI-compatible models configuration file:
vi "$(dirname "$(llm logs path)")"/extra-openai-models.yaml
  1. Add the following and save:
- model_id: mistral-tiny
import autogen
config_list = [
{
'model': 'gpt-4',
'api_key': 'API_KEY'
}
]
llm_config={