Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import onnx | |
model_path = "./model.onnx" | |
fixed_model_path = model_path.replace(".onnx", ".fixed.onnx") | |
# # Load the ONNX model which should have last layer as Sigmoid. | |
# LGBM Models may sometime not add the Sigmoid op during export when using regression loss | |
onnx_model = onnx.load(model_path) | |
print(onnx_model) | |
onnx.checker.check_model(onnx_model) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from IPython.display import display, HTML | |
class DisplayEntities: | |
@classmethod | |
def display(cls, texts, grouped_entities): | |
html = [] | |
html.append(cls.get_style()) | |
for text, entities in zip(texts, grouped_entities): | |
html.append(cls.show_entities(text, entities)) | |
display(HTML("".join(html))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
import pandas as pd | |
import torch | |
import transformers | |
from accelerate import Accelerator | |
from datasets import Dataset | |
from torch.utils.data import DataLoader | |
from tqdm.auto import tqdm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import logging | |
import random | |
import time | |
from dataclasses import dataclass | |
from typing import Any | |
from tqdm.auto import tqdm | |
logger = logging.getLogger(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datasets import load_dataset, Dataset, DatasetDict | |
from sentence_transformers.losses import CosineSimilarityLoss | |
from sentence_transformers import SentenceTransformer | |
from setfit import SetFitModel, SetFitTrainer, sample_dataset | |
from sklearn.model_selection import train_test_split | |
import pandas as pd | |
import numpy as np | |
import json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Faster Implementation of Unsupervised Query Segmentation. | |
Uses vectorized operations | |
- author: @napsternxg | |
Unsupervised Query Segmentation Using only Query Logs [Mishra et. al. 2011] | |
https://www.microsoft.com/en-us/research/wp-content/uploads/2011/01/pp0295-mishra.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, jsonify, request, render_template | |
from queued_map import example_items | |
app = Flask(__name__) | |
@app.get("/") | |
@app.get("/<int:n>") | |
def home(n: int=10): | |
output = example_items(n) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
def async_decorator(acreate_fn): | |
async def _f(*args, **kwargs): | |
print(f"Decorated fn: {args=}, {kwargs=}. Sleeping.") | |
await asyncio.sleep(0.1) | |
return await acreate_fn(*args, **kwargs) | |
return _f | |
NewerOlder