Mensa-Beta-14B-Instruct
Mensa-Beta-14B-Instruct is based on the Qwen 2.5 14B modality architecture, designed to enhance the reasoning capabilities of 14B-parameter models. This model is optimized for general-purpose reasoning and answering, excelling in contextual understanding, logical deduction, and multi-step problem-solving. It offers improved comprehension, structured responses, and conversational intelligence.
Key Improvements
- Enhanced General Knowledge: The model provides broad knowledge across various domains, improving capabilities in answering questions accurately and generating coherent responses.
- Improved Instruction Following: Significant advancements in understanding and following complex instructions, generating structured responses, and maintaining coherence over extended interactions.
- Versatile Adaptability: More resilient to diverse prompts, enhancing its ability to handle a wide range of topics and conversation styles, including open-ended and structured inquiries.
- Long-Context Support: Supports up to 128K tokens for input context and can generate up to 8K tokens in a single output, making it ideal for detailed responses.
- Multilingual Proficiency: Supports over 29 languages, including English, Chinese, French, Spanish, Portuguese, German, Italian, Russian, Japanese, Korean, Vietnamese, Thai, Arabic, and more.
Quickstart with transformers
Here is a code snippet with apply_chat_template
to show you how to load the tokenizer and model and generate content:
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "prithivMLmods/Mensa-Beta-14B-Instruct"
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype="auto",
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
prompt = "What are the key principles of general-purpose AI?"
messages = [
{"role": "system", "content": "You are a helpful assistant capable of answering a wide range of questions."},
{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
generated_ids = model.generate(
**model_inputs,
max_new_tokens=512
)
generated_ids = [
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
]
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
Sample Inference
What is Palindrome and Write the Code for it !
Thought for 110 seconds
Okay, so a palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward. For example, "madam" is a palindrome because if you reverse the letters, it's still "madam". Similarly, "racecar" is also a palindrome.Response
To write a code for checking if a string is a palindrome, I can do it in several ways. Let me think of the most straightforward way.
First, I need to take the input string and reverse it. Then, compare the reversed string with the original string. If they are equal, then it's a palindrome; otherwise, it isn't.
But before that, maybe we should ignore cases and non-alphanumeric characters, depending on what exactly is required. Hmm, let me think—if I need to handle those cases, I can preprocess the input by converting all characters to lowercase (or uppercase) and removing any characters that are not letters or numbers. But if the problem says to consider all characters, then I don't need to do that.
Let's assume for now we just want to check if a string is a palindrome as it is. Let me write the code in Python.
So, first, take the input from the user and store it in a variable.
s = input("Enter a string: ")
Then, reverse the string. In Python, one way to reverse a string is by slicing. So, s[::-1] will give us the reversed string.
reversed_s = s[::-1]
Now, compare the original string with the reversed string.
if s == reversed_s: print("It's a palindrome!") else: print("Not a palindrome.")
Wait, that should do it.
Alternatively, maybe I can use a loop to check each corresponding pair of characters from both ends. So, for example, in "madam", compare first and last character ('m' and 'm'), then second and second-last ('a' and 'a'), and so on until the middle is reached. If any pair doesn't match, it's not a palindrome.
Hmm, that might be more efficient because as soon as one mismatch is found, we can break out of the loop. Let me try writing that version.
s = input("Enter a string: ") n = len(s) is_palindrome = True for i in range(n // 2): if s[i] != s[n - i -1]: is_palindrome = False break
if is_palindrome: print("It's a palindrome!") else: print("Not a palindrome.")
Hmm, that seems to work. So, this code iterates from the start of the string up to (but not including) the middle index. For each index i, it checks if the character at position i matches the character at position n - i - 1. If any pair doesn't match, is_palindrome becomes False and we break out of the loop. At the end, we print "It's a palindrome!" if all pairs matched; otherwise, "Not a palindrome."
Now, which approach is better? Well, both work, but the first one using slicing might be less efficient for very long strings because it creates a new reversed string, which could take up extra memory. The second approach is more memory-efficient as it doesn't create any additional data structures.
But for practical purposes, unless we're dealing with extremely large inputs, either method would work fine. So, perhaps the first approach is simpler and easier to read.
Wait, but what if the input string has uppercase letters or non-alphanumeric characters? Hmm, depending on the problem statement, these could affect whether it's a palindrome. For example, "Madam" (uppercase 'M') wouldn't be considered a palindrome in the first version of the code. Similarly, "A man, a plan, a canal: Panama" would not be recognized as a palindrome.
So, maybe we should preprocess the string to ignore case and non-alphanumeric characters. Let's adjust the code accordingly.
First, import the regular expressions module (re) so that I can use regex for cleaning the input.
import re
s = re.sub('[^a-zA-Z0-9]', '', s).lower()
This line removes all non-alphanumeric characters from the string and converts it to lowercase. So, "Madam" becomes 'madam', and "A man, a plan, a canal: Panama" becomes 'amanaplanacanalpanama'.
Alternatively, if I don't want to use regex, I can iterate through each character, check if it's alphanumeric using the isalnum() method, and build a cleaned string.
cleaned_s = ''.join([c.lower() for c in s if c.isalnum()])
Hmm, that seems okay. So, now, after cleaning, we compare the cleaned string with its reverse. Hmm.
Wait, hmm—if I do this preprocessing before comparing, then my palindrome checker will treat "Madam" as a palindrome, which is probably correct. But for cases where the original string includes uppercase letters or non-alphanumeric characters, but they are supposed to be ignored, then that's the right approach.
But if the problem requires that all characters (including case and punctuation) must be considered, then I shouldn't do any preprocessing.
Hmm, so it's important to know the exact requirements. For example, "Madam" is not a palindrome because of the capital 'M', but "Madam Im Adam" would require ignoring spaces and 'I' versus lowercase 'i'.
So, for now, perhaps we'll write two versions: one that checks as-is, and another that preprocesses to ignore case and non-alphanumeric characters.
Hmm. So, I think I should present both methods.
Wait, hmm—if the problem is about numbers, like 12321 or 12345, then it's straightforward because numbers don't have cases. Hmm, but in some languages (like Python), numbers are treated as strings for certain operations, so it's all okay.
Hmm. So, to sum up: there are two main approaches:
- Reverse the string and compare.
- Check each pair of characters from both ends.
And we can preprocess the input to ignore case and non-alphanumeric characters if required.
Let me write both versions for clarity.
To determine if a string is a palindrome, we need to check if it reads the same forwards and backwards. Here are two approaches to solve this problem in Python:
Approach 1: Reverse the String and Compare
This approach involves reversing the entire string and then comparing it with the original.
s = input("Enter a string: ")
reversed_s = s[::-1]
if s == reversed_s:
print("It's a palindrome!")
else:
print("Not a palindrome.")
Approach 2: Compare Characters from Both Ends
This approach iterates through the first half of the string and compares each character with its corresponding character from the end.
s = input("Enter a string: ")
n = len(s)
is_palindrome = True
for i in range(n // 2):
if s[i] != s[n - i -1]:
is_palindrome = False
break
if is_palindrome:
print("It's a palindrome!")
else:
print("Not a palindrome.")
Handling Case Sensitivity and Non-Alphanumeric Characters
If the problem requires ignoring case and non-alphanumeric characters, we can preprocess the string.
import re
s = input("Enter a string: ")
cleaned_s = re.sub('[^a-zA-Z0-9]', '', s).lower()
reversed_s = cleaned_s[::-1]
if cleaned_s == reversed_s:
print("It's a palindrome!")
else:
print("Not a palindrome.")
Alternatively, without using regular expressions:
s = input("Enter a string: ")
cleaned_s = ''.join([c.lower() for c in s if c.isalnum()])
reversed_s = cleaned_s[::-1]
if cleaned_s == reversed_s:
print("It's a palindrome!")
else:
print("Not a palindrome.")
Example
For the input "Madam", the second approach with preprocessing would correctly identify it as a palindrome, whereas the first approach (without preprocessing) would not.
Choose the appropriate method based on the problem requirements. If case and non-alphanumeric characters need to be ignored, use the version that preprocesses the string. Otherwise, use the simpler versions.
Intended Use
General-Purpose Reasoning:
Designed for broad applicability, assisting with logical reasoning, answering diverse questions, and solving general knowledge problems.Educational and Informational Assistance:
Suitable for providing explanations, summaries, and research-based responses for students, educators, and general users.Conversational AI and Chatbots:
Ideal for building intelligent conversational agents that require contextual understanding and dynamic response generation.Multilingual Applications:
Supports global communication, translations, and multilingual content generation.Structured Data Processing:
Capable of analyzing and generating structured outputs, such as tables and JSON, useful for data science and automation.
Limitations
Potential Bias in Responses:
While designed to be neutral, outputs may still reflect biases present in training data.Inconsistent Outputs in Creative Tasks:
May produce variable results in storytelling and highly subjective topics.Limited Real-World Awareness:
Does not have access to real-time events beyond its training cutoff.Error Propagation in Extended Outputs:
Minor errors in early responses may affect overall coherence in long-form outputs.Prompt Sensitivity:
The effectiveness of responses may depend on how well the input prompt is structured.
- Downloads last month
- 0
Model tree for prithivMLmods/Mensa-Beta-14B-Instruct
Base model
Qwen/Qwen2.5-14B