--- library_name: transformers tags: - code license: apache-2.0 language: - en pipeline_tag: text-generation --- # Model Card for Model ID ## Model Details ### Model Description This model is fined-tuned based of Gemma model by Google's Gemini family and trained for generating general python codes, from Machine learning, to Web developing and data processing. - **Developed by:** Ali Bidaran - **Language(s) (NLP):** English ## Uses This model can be used for generating python codes in different usages such as data processing, designing ML and DL algorithms and implementing the backends of web applications with common frameworks such as Flask. Users can obtain the generated text by giving required prompts and instructions to the model. ### Direct Use ``` python import torch from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig, GemmaTokenizer model_id = "alibidaran/Gemma2_Python_instruction" bnb_config = BitsAndBytesConfig( load_in_4bit=True, bnb_4bit_quant_type="nf4", bnb_4bit_compute_dtype=torch.bfloat16 ) tokenizer = AutoTokenizer.from_pretrained(model_id) model = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=bnb_config, device_map={"":0}) prompt = """ Connect to a MongoDB database, select all documents from the collection ‘customers’ where the 'age' field is greater than 30 and the 'gender' field is 'female'. Then, for each selected document, retrieve the corresponding document from another collection called 'orders' based on the 'customer_id' field. Finally, display the documents in ascending order based on the 'last_name' field. The expected time complexity for retrieving the documents from the 'customers' collection should be O(n), where n is the total number of documents in the collection. The expected time complexity for retrieving the corresponding documents from the 'orders' collection for each selected document should also be O(n), where n is the total number of selected documents. """ text=f" ##Instruction: {prompt}: ##Output " inputs=tokenizer(text,return_tensors='pt').to('cuda') outputs=model.generate(**inputs,max_new_tokens=400,do_sample=True,top_p=0.92,top_k=10,temperature=0.7) print(tokenizer.decode(outputs[0], skip_special_tokens=True)) ``` [More Information Needed]