This file contains hidden or 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 human_eval.data import write_jsonl, read_problems | |
from transformers import AutoTokenizer, AutoModelForCausalLM | |
import torch | |
problems = read_problems() | |
tokenizer = AutoTokenizer.from_pretrained("mistralai/Mixtral-8x7B-v0.1", trust_remote_code=True) | |
model = AutoModelForCausalLM.from_pretrained( | |
"merged_thing", | |
torch_dtype=torch.bfloat16, |
This file contains hidden or 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
base_model: openlm-research/open_llama_3b_v2 | |
base_model_config: openlm-research/open_llama_3b_v2 | |
model_type: LlamaForCausalLM | |
tokenizer_type: LlamaTokenizer | |
load_in_8bit: false | |
load_in_4bit: false | |
strict: false | |
push_dataset_to_hub: | |
datasets: | |
- path: data1.json |
This file contains hidden or 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
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
imageURI == null | |
? Text('No image selected.') | |
: Image.file(imageURI, width: 300, height: 200, fit: BoxFit.cover), |
This file contains hidden or 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
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Scaffold( | |
appBar: AppBar( | |
title: Text('TFLite Example'), | |
backgroundColor: Colors.transparent | |
), |
This file contains hidden or 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 'package:flutter/material.dart'; | |
import 'package:image_picker/image_picker.dart'; | |
import 'dart:io'; | |
import 'package:tflite/tflite.dart'; |
This file contains hidden or 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
extension UIColor { | |
public convenience init?(hex: String) { | |
let r, g, b, a: CGFloat | |
if hex.hasPrefix("#") { | |
let start = hex.index(hex.startIndex, offsetBy: 1) | |
let hexColor = String(hex[start...]) | |
if hexColor.count == 8 { | |
let scanner = Scanner(string: hexColor) |
This file contains hidden or 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
coreml_model = coremltools.converters.sklearn.convert(model) | |
coreml_model.author = 'Your Name' | |
coreml_model.license = 'MIT' | |
coreml_model.short_description = 'Sentiment polarity LinearSVC.' | |
coreml_model.input_description['input'] = 'Features extracted from the text.' | |
coreml_model.output_description['classLabel'] = 'The most likely polarity (positive or negative), for the given input.' | |
coreml_model.output_description['classProbability'] = 'The probabilities for each class label, for the given input.' | |
coreml_model.save('SentimentPolarity.mlmodel') |
This file contains hidden or 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
features = np.vectorize(features) | |
X = features(reviews[:, 1]) | |
y = reviews[:, 0] |
This file contains hidden or 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
clf = Pipeline([("dct", DictVectorizer()), ("svc", LinearSVC())]) | |
params = { | |
"svc__C": [1e15, 1e13, 1e11, 1e9, 1e7, 1e5, 1e3, 1e1, 1e-1, 1e-3, 1e-5] | |
} | |
gs = GridSearchCV(clf, params, cv=10, verbose=2, n_jobs=-1) | |
gs.fit(X, y) | |
model = gs.best_estimator_ |
This file contains hidden or 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
def features(sentence): | |
stop_words = stopwords.words('english') + list(punctuation) | |
words = word_tokenize(sentence) | |
words = [w.lower() for w in words] | |
filtered = [w for w in words if w not in stop_words and not w.isdigit()] | |
words = {} | |
for word in filtered: | |
if word in words: | |
words[word] += 1.0 | |
else: |
NewerOlder