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 typing import Dict, Union | |
from huggingface_hub import get_safetensors_metadata | |
import argparse | |
import sys | |
# Example: | |
# python get_gpu_memory.py Qwen/Qwen2.5-7B-Instruct | |
# Dictionary mapping dtype strings to their byte sizes | |
bytes_per_dtype: Dict[str, float] = { |
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
def feature_template(self, state, sentence): | |
feature_list = np.empty((0), int) | |
stack = state.stack | |
buffer = state.buffer | |
ld = state.ld | |
rd = state.rd | |
form = sentence.form | |
pos = sentence.pos | |
lemma = sentence.lemma | |
morph = sentence.morph |
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
def train(self, train_data): | |
print("In trainer...") | |
u= np.zeros(self.weights.shape, dtype=np.int32) | |
q=0 | |
for epoch in range(0,1): | |
correct=0 | |
print("epoch: ",epoch+1) | |
i=0 | |
for data in train_data: | |
q += 1 |
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
def generate_tree(self, node): | |
#print(node) | |
if isinstance(self.find(self.copy_table, node)[1], (list,)): | |
item = self.find(self.copy_table, node)[1] | |
item_x = self.find(self.copy_table, node)[2] | |
item_y = self.find(self.copy_table, node)[3] | |
self.copy_table.remove(node) | |
if item_x[0]==0: | |
x=self.copy_table_reversed[item_x[1]] |
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
#prod -> right-hand side one element | |
nt -> left-hand side non-terminal | |
count -> true, if prod is in left | |
def create_prod_combinations(prod, nt, count): | |
numset = 1 << count | |
new_prods = [] | |
for i in range(numset): | |
nth_nt = 0 |