Skip to content

Instantly share code, notes, and snippets.

View jogonba2's full-sized avatar
🏠
Working from home

José González jogonba2

🏠
Working from home
View GitHub Profile
@jogonba2
jogonba2 / prototype_tuning.py
Last active March 28, 2025 18:42
Prototype tuning model
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "2"
from torch.nn import functional as F
from torch import nn
import torch
from typing import Optional
from sentence_transformers import SentenceTransformer
from transformers.modeling_outputs import SequenceClassifierOutput
from datasets import Dataset
@jogonba2
jogonba2 / grpo_encoder_decoder_summarization.py
Last active March 28, 2025 10:47
GRPO from deepseek r1 for summarization using encoder-decoder models
import gc
from copy import deepcopy
from dataclasses import dataclass
from typing import Tuple
import evaluate
import nltk
import torch
from datasets import Dataset, DatasetDict, load_dataset
from torch import FloatTensor, LongTensor
@jogonba2
jogonba2 / grpo.py
Last active March 7, 2025 18:04
Group Relative Policy Optimization from DeepSeek R1-zero just for fun
import gc
import re
from copy import deepcopy
from dataclasses import dataclass
import torch
from datasets import Dataset, DatasetDict, load_dataset
from math_verify import parse, verify
from peft import (
LoraConfig,
@jogonba2
jogonba2 / mbart_copy_generator.py
Last active December 31, 2023 18:49
MBartCopyGenerator
# coding=utf-8
# Copyright 2021, The Facebook AI Research Team and The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@jogonba2
jogonba2 / Simple_VAE.py
Created May 16, 2017 02:54
Example of Variational Autoencoder (Tensorflow)
import tensorflow as tf
import numpy as np
epochs = 10000
batch_size = 1500
d = 2
enc_1_hidden_units = 128
enc_2_hidden_units = 64
mean_hidden_units = std_hidden_units = 2
dec_1_hidden_units = 64
@jogonba2
jogonba2 / WattsStrogatz.py
Last active September 16, 2016 16:06
Watts-Strogatz model for generating small-words random graphs.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from random import random,choice
import networkx as nx
import matplotlib.pyplot as plt
import time
def watts(G,B):
@jogonba2
jogonba2 / Barabasi.py
Last active September 16, 2016 16:06
Barabasi-Albert model for generating scale-free random graphs.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from random import randint,random
import networkx as nx
import matplotlib.pyplot as plt
import time
# http://stackoverflow.com/questions/479236/how-do-i-simulate-biased-die-in-python #
def roll(probs):
@jogonba2
jogonba2 / SOM.py
Last active September 9, 2016 15:14
Self-organizing maps (SOM)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
from sklearn.datasets import load_iris
class SOM:
def __init__(self,X,it,size_x,size_y,min_w=0,max_w=1,a=0.01):
@jogonba2
jogonba2 / A5.py
Last active November 18, 2021 16:31
A5/1 python implementation
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# A5.py
#
# Author: overxfl0w13
#
def header():
print """
@jogonba2
jogonba2 / DES.py
Created September 2, 2015 16:59
DES encryption
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# DES.py
#
# Author: Overxfl0w13
import binascii