tags
Browse files
README.md
CHANGED
|
@@ -8,135 +8,146 @@ tags:
|
|
| 8 |
- instruct
|
| 9 |
- instructions
|
| 10 |
- code
|
|
|
|
| 11 |
metrics:
|
| 12 |
- rouge
|
| 13 |
language:
|
| 14 |
- en
|
| 15 |
widget:
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
*/
|
| 36 |
-
export class Document implements DocumentParams {
|
| 37 |
-
pageContent: string;
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
checkpoint = "distilbert-base-uncased-finetuned-sst-2-english"
|
| 132 |
-
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
| 133 |
-
model = AutoModelForSequenceClassification.from_pretrained(checkpoint)
|
| 134 |
-
sequences = ["I've been waiting for a HuggingFace course my whole life.", "So have I!"]
|
| 135 |
-
|
| 136 |
-
tokens = tokenizer(sequences, padding=True, truncation=True, return_tensors="pt")
|
| 137 |
-
output = model(**tokens)
|
| 138 |
-
example_title: model inference
|
| 139 |
|
|
|
|
|
|
|
| 140 |
inference:
|
| 141 |
parameters:
|
| 142 |
max_length: 96
|
|
|
|
| 8 |
- instruct
|
| 9 |
- instructions
|
| 10 |
- code
|
| 11 |
+
- instructiongen
|
| 12 |
metrics:
|
| 13 |
- rouge
|
| 14 |
language:
|
| 15 |
- en
|
| 16 |
widget:
|
| 17 |
+
- text: |
|
| 18 |
+
git lfs install
|
| 19 |
+
huggingface-cli lfs-enable-largefiles .
|
| 20 |
+
git lfs track "*.bin"
|
| 21 |
+
git add .
|
| 22 |
+
git commit -a -m "add fp32 chkpt"
|
| 23 |
+
git push
|
| 24 |
+
example_title: bash
|
| 25 |
+
- text: |
|
| 26 |
+
export interface DocumentParams {
|
| 27 |
+
pageContent: string;
|
| 28 |
+
|
| 29 |
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
| 30 |
+
metadata: Record<string, any>;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* Interface for interacting with a document.
|
| 35 |
+
*/
|
| 36 |
+
export class Document implements DocumentParams {
|
| 37 |
+
pageContent: string;
|
| 38 |
+
|
| 39 |
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
| 40 |
+
metadata: Record<string, any>;
|
| 41 |
+
|
| 42 |
+
constructor(fields?: Partial<DocumentParams>) {
|
| 43 |
+
this.pageContent = fields?.pageContent ?? this.pageContent;
|
| 44 |
+
this.metadata = fields?.metadata ?? {};
|
| 45 |
}
|
| 46 |
+
}
|
| 47 |
+
example_title: js
|
| 48 |
+
- text: |
|
| 49 |
+
def merge(left, right):
|
| 50 |
+
if len(left) == 0:
|
| 51 |
+
return right
|
| 52 |
|
| 53 |
+
if len(right) == 0:
|
| 54 |
+
return left
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
+
result = []
|
| 57 |
+
index_left = index_right = 0
|
| 58 |
|
| 59 |
+
while len(result) < len(left) + len(right):
|
| 60 |
+
if left[index_left] <= right[index_right]:
|
| 61 |
+
result.append(left[index_left])
|
| 62 |
+
index_left += 1
|
| 63 |
+
else:
|
| 64 |
+
result.append(right[index_right])
|
| 65 |
+
index_right += 1
|
| 66 |
+
|
| 67 |
+
if index_right == len(right):
|
| 68 |
+
result += left[index_left:]
|
| 69 |
+
break
|
| 70 |
+
|
| 71 |
+
if index_left == len(left):
|
| 72 |
+
result += right[index_right:]
|
| 73 |
+
break
|
| 74 |
+
|
| 75 |
+
return result
|
| 76 |
+
example_title: merge
|
| 77 |
+
- text: >
|
| 78 |
+
import pandas as pd
|
| 79 |
+
|
| 80 |
+
import plotly.graph_objects as go
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
df =
|
| 84 |
+
pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2014_apple_stock.csv')
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
fig = go.Figure(go.Scatter(x = df['AAPL_x'], y = df['AAPL_y'],
|
| 88 |
+
name='Share Prices (in USD)'))
|
| 89 |
+
|
| 90 |
+
fig.update_layout(title='Apple Share Prices over time (2014)',
|
| 91 |
+
plot_bgcolor='rgb(230, 230,230)',
|
| 92 |
+
showlegend=True)
|
| 93 |
+
|
| 94 |
+
fig.show()
|
| 95 |
+
example_title: plot
|
| 96 |
+
- text: |
|
| 97 |
+
from spellchecker import SpellChecker
|
| 98 |
+
|
| 99 |
+
spell = SpellChecker()
|
| 100 |
+
|
| 101 |
+
def check_word_spelling(word: str):
|
| 102 |
+
misspelled = spell.unknown([word])
|
| 103 |
+
return len(misspelled) == 0
|
| 104 |
+
|
| 105 |
+
def eval_and_replace(text: str, match_token: str = "- "):
|
| 106 |
+
if match_token not in text:
|
| 107 |
+
return text
|
| 108 |
+
else:
|
| 109 |
+
while True:
|
| 110 |
+
full_before_text = text.split(match_token, maxsplit=1)[0]
|
| 111 |
+
before_text = [
|
| 112 |
+
char for char in full_before_text.split()[-1] if char.isalpha()
|
| 113 |
+
]
|
| 114 |
+
before_text = "".join(before_text)
|
| 115 |
+
full_after_text = text.split(match_token, maxsplit=1)[-1]
|
| 116 |
+
after_text = [char for char in full_after_text.split()[0] if char.isalpha()]
|
| 117 |
+
after_text = "".join(after_text)
|
| 118 |
+
full_text = before_text + after_text
|
| 119 |
+
if check_word_spelling(full_text):
|
| 120 |
+
text = full_before_text + full_after_text
|
| 121 |
+
else:
|
| 122 |
+
text = full_before_text + " " + full_after_text
|
| 123 |
+
if match_token not in text:
|
| 124 |
+
break
|
| 125 |
+
return text
|
| 126 |
+
|
| 127 |
+
text = "I- am- a go- od- boy"
|
| 128 |
+
eval_and_replace(text)
|
| 129 |
+
example_title: spell check
|
| 130 |
+
- text: >
|
| 131 |
+
import torch
|
| 132 |
+
|
| 133 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
checkpoint = "distilbert-base-uncased-finetuned-sst-2-english"
|
| 137 |
+
|
| 138 |
+
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
|
| 139 |
+
|
| 140 |
+
model = AutoModelForSequenceClassification.from_pretrained(checkpoint)
|
| 141 |
+
|
| 142 |
+
sequences = ["I've been waiting for a HuggingFace course my whole life.",
|
| 143 |
+
"So have I!"]
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
tokens = tokenizer(sequences, padding=True, truncation=True,
|
| 147 |
+
return_tensors="pt")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
|
| 149 |
+
output = model(**tokens)
|
| 150 |
+
example_title: model inference
|
| 151 |
inference:
|
| 152 |
parameters:
|
| 153 |
max_length: 96
|