Downloads · 30 days
79
0% of all-time downloads
Nethermind/Mpt-Instruct-DotNet-S
Mpt-Instruct-DotNet-S is a text generation model from Nethermind. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as cc-by-sa-3.0.
Code for use form .Net CSharp on CPU that runs on Windows, Mac M and Linux
Downloads · 30 days
79
0% of all-time downloads
All-time downloads
32K
Public
Repo size
51.5 GB
Likes
1
Public
Click a slice to open those files.
.bin38.2 GB · 100%
From the Hugging Face model README
Code for use form .Net CSharp on CPU that runs on Windows, Mac M and Linux
import torch
import transformers
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-neox-20b")
tokenizer.pad_token = tokenizer.eos_token
device = torch.device("cuda")
model_name = "Nethermind/Mpt-Instruct-DotNet-S"
config = transformers.AutoConfig.from_pretrained(model_name, trust_remote_code=True)
config.init_device = device
config.max_seq_len = 1024
config.attn_config['attn_impl'] = 'torch'
config.use_cache = False
model = transformers.AutoModelForCausalLM.from_pretrained(
model_name,
config=config,
torch_dtype=torch.bfloat16,
trust_remote_code=True,
ignore_mismatched_sizes=True,
# load_in_8bit=True # when low on GPU memory
)
model.eval()
INSTRUCTION_KEY = "### Instruction:"
RESPONSE_KEY = "### Response:"
PROMPT_FOR_GENERATION_FORMAT = """{system}
{instruction_key}
{instruction}
{response_key}
""".format(
system="{system}",
instruction_key=INSTRUCTION_KEY,
instruction="{instruction}",
response_key=RESPONSE_KEY
)
def give_answer(instruction="Create a loop over [0, 6, 7 , 77] that prints its contentrs", system="You are an experienced .Net C# developer. Below is an instruction that describes a task. Write a response that completes the request providing detailed explanations with code examples.", ):
question = PROMPT_FOR_GENERATION_FORMAT.format(system=system, instruction=instruction)
input_tokens = tokenizer.encode(question ,return_tensors='pt')
model.generate(input_tokens.to(device), max_new_tokens=min(512, 1024 - input_tokens.shape[1]), do_sample=False, top_k=1, top_p=0.95)
outputs = output_loop(tokenized_question)
answer = tokenizer.batch_decode(outputs, skip_special_tokens=True)
print(answer[0])
Finetuned for CSharp mosaicml/mpt-7b-instruct. Max context length is restricted to 1024 tokens.
data contained (most data was around 500 tokens long < 1000, except large code files):
IEthRpcModule : Short Q->Code, Explain Code X -> Step-By-Step (7k)