Skip to content

Instantly share code, notes, and snippets.

View osanseviero's full-sized avatar

Omar Sanseviero osanseviero

View GitHub Profile
/*
* Converts table from [[Header0, Header1, Header2], [Column0Val0, Column1Val0, Column2Val0], ...]
* to {Header0: [ColumnVal0, ...], Header1: [Column1Val0, ...], Header2: [Column2Val0, ...]}
*/
function convertTableToData(table) {
transposed = table[0].map((_, colIndex) => table.map(row => row[colIndex]));
result = {}
for(var i = 0; i < transposed.length; i++) {
header = transposed[i][0]
result[header] = transposed[i].slice(1, 4).map(String);
@osanseviero
osanseviero / push.py
Last active August 24, 2021 05:58
Upload CoreNLP models to the Hub
import os
import shutil
from huggingface_hub import Repository, HfApi, HfFolder
def get_model_card(lang):
model_card = """---
tags:
- corenlp
library_tag: corenlp
@osanseviero
osanseviero / extension.py
Created August 24, 2021 12:39
Question generation chrome extension
""" Chrome Manifest file: https://developer.chrome.com/docs/extensions/mv3/getstarted/
{
"manifest_version": 3,
"name": "Hugging Face Question Generator",
"version": "1.0",
"description": "Generate questions based on selected text",
"permissions": [
"contextMenus",
"storage",
"tabs",
@osanseviero
osanseviero / app.py
Last active April 1, 2022 11:44
Simple gradio demo
%%capture
!pip install gradio transformers sentencepiece
import gradio as gr
from transformers import pipeline
pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-en-es")
def predict(text):
@osanseviero
osanseviero / llama2.ipynb
Created July 18, 2023 20:39
Llama 2 fine-tune
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.