Mistral releases Codestral, its first generative AI model for code

Mistral, the French AI startup backed by Microsoft and valued at $6 billion, has released its first generative AI model for coding, dubbed Codestral. Codestral, like other code-generating models, is designed to help developers write and interact with code. It was trained on over 80 programming languages, including Python, Java, C++ and JavaScript, explains Mistral […]

© 2024 TechCrunch. All rights reserved. For personal use only.

Can Scale Become the ‘Data Foundry’ for AI?

Scale AI, which provides data labeling and annotation software and services to organizations like OpenAI, Meta, and the Department of Defense, this week announced a $1-billion funding round at a valuation of nearly $14 billion, putting it in a prime position to capitalize on the generative AI revolution.

Alexandr Wang founded Scale AI back in 2016 to provide labeled and annotated data, primarily for autonomous driving systems. At the time, self-driving vehicles seemed to be just around the corner, but getting the vehicles on the road in a safe manner has proven to be a tougher problem than originally anticipated.

Scale AI founder and CEO Alexandr Wang

With the explosion of interested in GenAI over the past 18 months, the San Francisco-based company saw the need explode for labeling and annotating text data, which is the primary input for large language models (LLMs). Scale AI employs a large network of hundreds of contractors around the world who perform the work of labeling and annotating clients’ data, which involves things like describing pieces of text or conversation, assessing the sentiment, and overall establishing the “ground truth” of the data so it can be used for supervised machine learning.

In addition to providing data labeling and annotation services, Scale AI also develops software, including a product called the Scale Data Engine that is geared toward helping customers create their own AI-ready data–or in other words, to create a data foundry.

The Scale Data Engine provides a framework for the “end-to-end AI lifecycle,” the company says. The software helps to automate the collection, curation, and labeling or annotating text, image, video, audio, and sensor data. It provides data management for unstructured data, direct integration with LLMs from OpenAI, Cohere, Anthropic, and Meta (among others), management of the reinforcement learning from human feedback (RLHF) workflow, and “red teaming” models to ensure security.

ScaleAI also develops Scale GenAI Platform, which it bills as a “full stack” GenAI product that helps users to optimize their LLM performance, provides automated model comparisons, and helps users implement retrieval augmented generation (RAG) to boost the quality of their LLM applications.

Scale AI’s product architecture

It’s all about expanding customers’ ability to scale up the most critical asset for AI: their data.

“Data abundance is not the default; it’s a choice. It requires bringing together the best minds in engineering, operations, and AI,” Wang said in a press release. “Our vision is one of data abundance, where we have the means of production to continue scaling frontier LLMs many more orders of magnitude. We should not be data-constrained in getting to GPT-10.”

This week’s $1 billion Series F round solidifies Scale AI as one of the leaders in an emerging field of data management for GenAI. Companies are rushing to adopt GenAI, but often find their data is ill-prepared for use with LLMs, either for training new models, fine-tuning existing ones, or just feeding data into existing LLMs using prompts and retrieval-augmented generation (RAG) techniques.

The round includes nearly two dozen investors, including Nvidia, Meta, Amazon, and the investment arms of Intel, AMD, Cisco, and ServiceNow. The $13.8 billion is nearly double the $7.3 billion valuation Scale AI had in 2021, and puts the company, which reportedly had revenues of $700 million last year, on track for an initial public offering (IPO).

Scale AI has worked with a range of companies, including iRobot, maker of the Roomba vacuum machine; Toyota, Nuvo, Amazon, and Salesforce. It signed a $249-million contract with the Department of Defense in 2022, and it’s done work with the United States Airforce.

“As an AI community we’ve exhausted all of the easy data, the internet data, and now we need to move on to more complex data,” Wang told the Financial Times. “The quantity matters but the quality is paramount. We’re no longer in a paradigm where more comments off Reddit are going to magically improve the models.”

Microsoft Launches Telegram Bot Powered by Copilot

Microsoft Launches Telegram Bot Powered by Copilot

Microsoft has introduced a new Copilot Telegram bot, allowing users to search, chat, and ask questions to an AI assistant for various purposes.

Currently, in its beta phase, Copilot for Telegram offers its services for free to users on mobile or desktop, exclusively supporting text-based interactions.

How to Use Copilot for Telegram?

Getting started with Copilot for Telegram is simple. Users can access it through the Telegram desktop & mobile app, or via the Telegram web interface. Alternatively, they can search for Copilot by typing @CopilotOfficialBot in Telegram’s search bar.

Upon discovery, the bot will prompt users to provide their Telegram phone number to connect.

Microsoft has highlighted the Copilot Chatbot’s ability to deliver comprehensive responses, ranging from quick facts to in-depth research powered by Bing Search. It can further assist with travel plans, offer fitness guidance, provide entertainment updates, and more.

Copilot’s content generation is based on language patterns extracted from the internet. As a result, its responses may occasionally resemble existing online content, or it may generate similar responses for users with similar prompts.

Microsoft Copilot

In September 2023, Microsoft launched Copilot, advertising it as your everyday AI companion. The company has highlighted that Copilot leverages web context, your work data, and real-time PC activities to deliver personalised support, all while prioritising users’ privacy and security.

The tool has now been integrated into several Microsoft offerings, including Windows 11, and Microsoft 365, as well as the web ecosystem with Edge and Bing, offering a simple and seamless experience.

At Microsoft Build 2024, significant updates to Microsoft Copilot were unveiled, signalling a strategic shift towards enhancing employee self-service and productivity through advanced AI capabilities.

The Copilot Studio introduces independent agent capabilities, allowing Copilots to act autonomously based on events, expanding their utility beyond just conversations.

Further, custom Copilots enable users to tailor AI assistants to specific roles and industries, offering enhanced information retrieval and contextual insights from SharePoint content.

Complementing these advancements, the introduction of Copilot+ PCs promises unparalleled computing power and AI integration, aiming to revolutionise user experiences and productivity on Windows platforms, emphasising Microsoft’s commitment to innovation in conversational AI and intelligent computing.

The post Microsoft Launches Telegram Bot Powered by Copilot appeared first on AIM.

GPT-5 is Arriving Sooner Than Ever

OpenAI GPT-5 Safety and Security

Yesterday, OpenAI announced their new Safety and Security Committee which will be led by Sam Altman and OpenAI Board Directors Bret Taylor, Adam D’Angelo, and Nicole Seligman. The committee will be accountable for making recommendations to the full Board on safety and security decisions for OpenAI projects.

The committee will also include technical and policy experts from OpenAI, including, Aleksander Madry (Head of Preparedness), Lilian Weng (Head of Safety Systems), John Schulman (Head of Alignment Science), Matt Knight (Head of Security), and Jakub Pachocki (Chief Scientist) who recently took over Ilya Sutskever’s position. Former cybersecurity officials, Rob Joyce and Jon Carlin will also be consulted.

Interestingly, the announcement comes at a time when the next superior model has been confirmed to be in works. Altman even hinted at the same at the recent Microsoft Build 2024 event.

90-Days Window

The company blog says,“OpenAI has recently begun training its next frontier model and we anticipate the resulting systems to bring us to the next level of capabilities on our path to AGI.” This probably being a direct hint at GPT-5. Satya Nadella had also indirectly confirmed the same in a recent interview.

Satya Nadella, when asked if he tried GPT-5, initially responded, "Oh yes, of course." When prompted to correct himself, he did not deny the statement. pic.twitter.com/g2b2HXskXX

— Ale𝕏 Fazio (@alxfazio) May 21, 2024

The initial task of the Safety and Security Committee will focus on evaluating and developing OpenAI’s processes and safeguards over the next 90 days. Post which, the committee will share the recommendations to the complete Board for review and then public announcement.

Interestingly, GPT-5 was rumoured to release during the summer which coincides with the 90 days window for evaluation. However, with the US elections slated to take place in November this year, it is also presumed that GPT-5 may be released after that.

The upcoming GPT-5 model is said to have superior qualities and even probably act as an AI agent. It is said to have multimodal capabilities supporting text, image, audio and video from the start. The latest text-to-video generation model Sora will also be embedded into the system.

While the company is gearing up for its next model, the Safety and Security committee announcement is likely a preemptive step from the company’s side, considering how the safety alignment team was recently abandoned after Ilya and Jan Leike’s exit. Further, users were quick to react to the announcement with many being critical of the same.

Source: X

The post GPT-5 is Arriving Sooner Than Ever appeared first on AIM.

Hating on Python is Literally a Skill Issue

Hating on Python is Literally a Skill Issue

The internet is buzzing, and once again, Python finds itself in the crosshairs. A user sparked a lively debate with her post on X: “Hating on Python is literally a skill issue.” This simple statement set off a firestorm of opinions.

The point, as succinctly captured in the phrase, suggests that those who criticise Python might be struggling with the language’s simplicity and accessibility. It’s reminiscent of the common gripe about C++: “C++ is terrible because of memory leaks.”

Python, with its straightforward syntax and wide applicability, is easy to pick up but deceptively challenging to master in nuanced, efficient coding.

Some argue that “Python is easy to hate on because it’s a trash language that’s merely an abstraction anyway.” This critique is not uncommon.

Many developers accustomed to the power and precision of languages like C++ or Java often find Python’s abstract nature frustrating, especially when dealing with performance-intensive applications.

But What is the Issue?

Sanjay Nithin offers a more technical criticism saying, “Can’t handle environments properly, properly handled environments aren’t easy to deploy, takes a lot of time and space to process.” These are legitimate concerns, especially in production environments where efficiency and scalability are paramount.

Python is a good language pic.twitter.com/XFKvXPkb2H

— Mark Tenenholtz (@marktenenholtz) September 11, 2023

Some people have positive criticism about Python and say that lack of constraints such as typing encourages bad practices throughout the ecosystem.

This highlights a frequent complaint among seasoned developers that Python’s flexibility can lead to sloppy code and poor software engineering practices if not managed properly, which has been a long discussed issue.

Conversely, Andre Infante argues that programming languages are designed to minimise errors: “The whole point of programming languages is to protect you from your own mistakes and make it harder to make them. Skill issues are language issues.”

The ease of making mistakes in Python is a double-edged sword—it makes the language accessible but also more prone to user error.

“It is hard to beat Java at speed. I’m an ML engineer, and Python is slow. Do write Java whenever you can.” This critique underscores Python’s performance limitations compared to more optimised languages like Java.

AGI will be built on Python

Despite these criticisms, supporters of Python are unwavering: “Seems 100% true, Python is based and will be based.” This sentiment reflects the strong community support and the language’s entrenchment in various tech domains, particularly AI and data science.

Proficiency and comfort with Python come from skill and familiarity, not inherent flaws in the language. Earlier, AIM made a point that the most frustrating programming language is also the one that you work on the most.

As the market shows, Python’s popularity is no fluke. It’s a testament to its broad applicability and the skill of those who wield it effectively. According to Statista, Python is the most popular programming language.

python is the best language actually. you can tell because it's the most popular. the market has spoken. pic.twitter.com/WZgUhDvAPw

— xlr8harder (@xlr8harder) May 29, 2024

Python’s dynamic typing can lead to subtle bugs that may not be caught until runtime, and its performance can sometimes lag behind that of compiled languages like C++. Apart from people heavily discussing how dynamic typing is one of the worst things about Python, it is also the community that makes it worse for people.

“Python is great for scripting random tasks and calling functions implemented in C. It is not great for building applications.” This pragmatic take acknowledges Python’s strengths and weaknesses, recognizing its utility in specific contexts.

In the end, hating Python may indeed be a skill issue. “Only a bad craftsperson blames their tools.” Python’s simplicity and versatility have made it a staple in the programming world. While it may not be perfect for every application, its accessibility and vast library support make it an indispensable tool for many.

Meanwhile, this debate seems to be forgetting the fact that English is the hottest programming language. Moreover, Microsoft is now also allowing people to code in their native languages, which could even mark the end of Python. The conversation of ‘skill issue’ is simply going to shift to whoever prompts the Copilot the best.

The post Hating on Python is Literally a Skill Issue appeared first on AIM.

Adobe vs Canva for Enterprise 

Adobe vs Canva for Enterprise

Canva, which is popular among companies in the higher education sector, stole the spotlight with the announcement of Canva Enterprise. With an all-in-one solution, Canva aims to empower large organisations to effortlessly revolutionise their visual communication, content creation, and collaborative efforts.

Tailored for extensive teams of over 100 members, Canva Enterprise caters primarily to mid-to-large businesses with intricate demands, from security and reporting to brand management and integrations.

Melanie Perkins, co-founder and CEO of Canva, expressed enthusiasm about the launch and said, “As the demand for visual content soars, navigating organisational complexity is more challenging than ever.”

Meanwhile, Adobe has stepped up with Adobe Express for Enterprise, aiming to supercharge marketing content creation for businesses while extending user-friendly, on-brand content production across departments like communications and sales.

The latest pack of features offers brand control, bulk creation, custom template generation, and the innovative Firefly tool, empowering marketers to seamlessly repurpose content for upcoming campaigns and adapt campaign assets for diverse regions.

Creative Users

When it comes to global reach, Canva takes the crown, boasting users in over 190 countries worldwide, which translates to a staggering 97.4% of the world’s nations.

With a whopping 175 million monthly users, Canva’s growth is undeniable, hitting the 100 million milestone in October 2021 and adding an extra 10 million users by the close of 2022.

About 90% of Fortune 500 companies rely on Canva, including over 450 of the largest companies in the United States alone.

On the Adobe side, data suggests that its Creative Cloud subscription service amassed approximately 23 million active users by mid-2022. Since its launch in 2012 with 1.4 million subscribers, Creative Cloud has experienced rapid expansion, with projections indicating a potential total subscriber count of 30 million by the end of 2024.

Adobe’s flagship tools like Photoshop and Illustrator dominate the professional creative landscape, empowering over 90% of creative professionals globally.

On The Revenue Side

Comparing the profit and revenue situations of Canva and Adobe reveals interesting insights into the dynamics of the two companies in the creative software market.

Adobe, with its established Creative Cloud offerings, is a dominant player in the industry. Its fiscal year 2023 revenue of approximately $11.5 billion underscores the significant contribution of Creative Cloud to the company’s overall earnings.

As of the fourth quarter of FY 2023, its creative revenue grew to $3.00 billion, representing 12% year-over-year growth or 14% in constant currency. Document Cloud revenue was $721 million, representing 16% year-over-year growth or 17% in constant currency.

On the other hand, Canva, though newer to the scene compared to Adobe, has made remarkable strides in revenue generation. Surpassing $1 billion in revenue in 2022 while maintaining positive cash flow since 2020, the company showcased rapid growth and market acceptance.

The annual recurring revenue of $2.3 billion and a valuation of $26 billion position Canva as a formidable contender in the creative software landscape. However, the decision to delay its IPO until 2025 or 2026 suggests a cautious approach, indicating a focus on further expansion and consolidation before entering the public market.

How much can you get away with when it comes to copying competing software products, and get away with it. Apparently almost 1:1 😳
I thought they would at least be a little discrete about it, but no…
Canva vs Adobe Express.#canva #adobe #adobeexpress #ui #ux pic.twitter.com/ART5aJxZEu

— Thomas Broen (@tbroen) January 10, 2024

The Indian Market

Back home in India, Canva ranks as the fifth largest player, demonstrating a strong belief in the creator economy. According to statements released by Canva, there are 240,000 freelancers actively utilising the platform in the country.

With respect to pricing, Canva Pro caters to individual users in India at the cost of INR 500 per month or INR 4,000 per year. Further, Canva has introduced its AI-driven design platform, Magic Studio, offering features available in 11 Indian languages, a move aimed at enhancing accessibility and user experience within the vast Indian market.

On the other hand, Adobe’s Creative Cloud garnered substantial traction for application development in India, securing the second position among its top three geographies.

With 5,945 customers, India accounts for approximately 10.55% of Adobe Creative Cloud’s user base. The membership for individuals in India is priced at INR 2,700 per month based on an annual subscription, with special discounts available for existing Creative Suite customers.

In Conclusion

While Adobe boasts a longer history and established presence in the industry, Canva’s rapid revenue growth and market acceptance position it as a formidable contender.

Ultimately, the choice between Canva and Adobe for enterprise-level visual communication solutions depends on factors such as organisational requirements, user preferences, and specific use cases.

The post Adobe vs Canva for Enterprise appeared first on AIM.

Intuit is Certified as a Best Firm for Data Scientists

Intuit is certified as the Best Firm For Data Scientists to work for by Analytics India Magazine (AIM) through its workplace recognition programme.

The Best Firm For Data Scientists certification surveys a company’s data scientists and analytics employees to identify and recognise organisations with great company cultures. AIM analyses the survey data to gauge the employees’ approval ratings and uncover actionable insights.

Intuit’s AI Excellence

“At Intuit AI, I am inspired everyday by the exceptional team of ML scientists and engineers I work with. We are dedicated to pushing the boundaries of machine learning and AI to deliver outstanding benefit to our customers. Our teams harness deep algorithmic craft, innovative thinking, and cutting-edge engineering practices to build models and systems that empower millions to thrive financially. We are committed to nurturing our teams, fueled by mentorship, access to the latest tech stack, and a vibrant AI culture. Intuit stands out as the best environment for those looking to make a meaningful impact in AI and data science” said Anusha Mujumdar, Manager 2 Data & Analytics at Intuit.

Intuit’s Customer-Centric AI Approach

“As a member of Intuit’s AI team, I am proud to work alongside a remarkable group of technologists. We are at the forefront of cutting-edge innovation in AI, including GenAI. We also take Responsible AI seriously. What sets our team apart is our unwavering focus on the customer. We are constantly dedicated to creating products that make our customers’ lives easier, allowing them to save both time and money without any hassle. Our product is delivered with utmost confidence and a commitment to excellence” said Mithun Ghosh, Manager 2 Data Science at Intuit.

Addressing the Talent Crunch in the Analytics Industry

The analytics industry currently faces a talent crunch, and attracting good employees is one of the most pressing challenges that enterprises are facing.

The certification by Analytics India Magazine is considered a gold standard in identifying the best data science workplaces and companies participate in the programme to increase brand awareness and attract talent.

Best Firms for Data Scientists is the biggest data science workplace recognition programme in India. To nominate your organisation for the certification, please fill out the form here.

The post Intuit is Certified as a Best Firm for Data Scientists appeared first on AIM.

Yann LeCun Puts a Brake on Musk’s AGI Timeline

yann lecun vs elon musk

xAI chief Elon Musk and Meta’s chief AI scientist Yann LeCun, recently engaged in friendly banter on X, and it looks like there is no end in sight. And LeCun is clearly winning the argument, or more accurately, is successfully derailing Musk’s plans to build a new supercomputer with 100,000 NVIDIA GPUs and achieve AGI next year.

Interestingly, the drama is unfolding on X rather than on Meta’s Threads, which was launched about a year ago. Meta and xAI are competitors, with both social media platforms building open-source LLMs that can provide real-time information.

Not sure if this is a deliberate move by Mark Zuckerburg or LeCun – who understands LLMs like no other – to pollute X with pessimist views, so Grok fails. “My relationship with X/Twitter is love/hate,” quipped LeCunn, further fuelling speculation.

This development comes in the backdrop of xAI announcing a Series B funding round of $6 billion to expand its team, making xAI the second-most valuable AI startup at a $24 billion valuation, outperformed only by OpenAI, which is at an $86 billion valuation.

It is also impressive to see it surpassed Anthropic in less than a year, which now stands as the third-most valuable AI startup at an $18 billion valuation.

Advises People to Not Join xAI

LeCun believes that LLMs that power generative AI products such as ChatGPT will never achieve the ability to reason and plan like humans, or achieve AGI. LeCun is of the opinion that animals are more intelligent than AI.

“General intelligence, artificial or natural, does not exist. Cats, dogs, humans and all animals have specialised intelligence,” said LeCun recently.

The banter between LeCun and Musk started after the latter invited people to join xAI’s mission.

“Join xAI if you can stand a boss who claims that what you are working on will be solved next year (no pressure),” responded LeCun, advising interested candidates against joining Musk’s company.

Further, he said that he likes Musk’s cars, rockets, solar panels, and satellite network but dislikes his vengeful politics, conspiracy theories, and hype.

LeCun believes he is politically correct because he is a “scientist, not a business or product person” unlike Musk.

When Musk questioned his contribution, as to how much research he conducted “in the last five years,” LeCun candidly replied saying, “Over 80 technical papers published since January 2022.”

A few days ago, LeCun clarified that FAIR has roughly 500 scientists and engineers, and he doesn’t run FAIR; Joelle Pineau does. “In fact, I don’t run anything, I’m nobody’s boss. I’m the Chief AI Scientist: I provide ideas and advice to teams,” he said.

xAI vs Meta

Musk recently told his investors that his goal is to have the supercomputer operational by fall 2025. Once completed, this supercomputer — comprising NVIDIA’s flagship H100 GPUs — will be at least four times larger than the biggest existing GPU clusters, including those built by Meta Platforms for training AI models, he told investors.

Currently, xAI is reportedly set to spend $10 billion on Oracle Cloud servers.

In an interview with Norway Wealth Fund CEO Nicolai Tangen on X Spaces, Musk revealed that training the Grok 2 model requires approximately 20,000 Nvidia H100 GPUs. He added that training the Grok 3 model and future versions will necessitate 100,000 Nvidia H100 GPUs.

In April, xAI introduced Grok-1.5V, a first-generation multimodal model. In addition to its strong text capabilities, Grok can process a wide variety of visual information, including documents, diagrams, charts, screenshots, and photographs.

Meanwhile, Musk’s Tesla, now headquartered in Austin, is also developing a Dojo supercomputer. NVIDIA provided 35,000 H100 GPUs to Tesla, paving the way for the breakthrough performance of FSD Version 12, their latest autonomous driving software based on Vision.

As far as Meta is concerned, LeCun recently confirmed that the company has obtained $30 billion worth of NVIDIA GPUs to train their AI models. Enough to run a small nation or even put a man on the moon in 1969.

Earlier this year, Zuckerberg announced that Meta is building massive compute infrastructure to train Llama 3 and will acquire 350,000 H100s by the end of this year, aiming for a total of almost 600,000 H100s worth of compute.

During the latest NVIDIA earnings call, the company said that the big highlight of the quarter was Meta’s announcement of Llama 3, their latest LLM, which was trained on a cluster of 24,000 H100 GPUs.

Llama 3 powers Meta AI, a new AI assistant available on Facebook, Instagram, WhatsApp, and Messenger. Using Meta AI, users can access real-time information from across the web without having to bounce between apps.

Interestingly, Meta AI Assistant is quite similar to xAI’s Grok, as both are generative AI applications on social media platforms and generate real-time information. Recently, Grok has faced criticism for generating hallucinated content on several occasions.

Meanwhile, Meta is yet to release the Llama 3 400B models, which are still in training. The company said that over the coming months, they will release multiple models with new capabilities, including multimodality, the ability to converse in multiple languages, a much longer context window, and stronger overall capabilities.

OpenAI is Likely to Reach AGI Before xAI and Meta

According to reports, Microsoft and OpenAI are also working on plans for a data centre project that could cost as much as $100 billion and include an AI supercomputer called Stargate, set to launch in 2028.

OpenAI chief Sam Altman recently proposed the concept of Universal Basic Compute, in which everyone would have access to a portion of GPT-7’s computing resources.

“I wonder if the future looks something more like Universal Basic Compute than Universal Basic Income, and everybody gets like a slice of GPT-7 compute,” said Altman, in the recent episode of the All-In Podcast.

Most recently, OpenAI announced that it had started training its next frontier model, GPT-5, and anticipates that it will bring the next level of capabilities on their path to achieve AGI.

Sadly, there is no convincing LeCun.

A few days ago, he took a dig at OpenAI, sarcastically saying: “Come work at ClosedAI. With AGI just around the corner, your shares will be worth 42 sextillionnollars. We can claw back your vested shares if you quit, unless you sign a non-disparagement agreement. Oh wait, sorry, we didn’t realise our contract was this harsh until someone published an article on it. You can keep them.”

The post Yann LeCun Puts a Brake on Musk’s AGI Timeline appeared first on AIM.

5 Python Best Practices for Data Science

python-ds
Image by Author

Strong Python and SQL skills are both integral to many data professionals. As a data professional, you’re probably comfortable with Python programming—so much that writing Python code feels pretty natural. But are you following the best practices when working on data science projects with Python?

Though it's easy to learn Python and build data science applications with it, it's, perhaps, easier to write code that is hard to maintain. To help you write better code, this tutorial explores some Python coding best practices which help with dependency management and maintainability such as:

  • Setting up dedicated virtual environments when working on data science projects locally
  • Improving maintainability using type hints
  • Modeling and validating data using Pydantic
  • Profiling code
  • Using vectorized operations when possible

So let’s get coding!

1. Use Virtual Environments for Each Project

Virtual environments ensure project dependencies are isolated, preventing conflicts between different projects. In data science, where projects often involve different sets of libraries and versions, Virtual environments are particularly useful for maintaining reproducibility and managing dependencies effectively.

Additionally, virtual environments also make it easier for collaborators to set up the same project environment without worrying about conflicting dependencies.

You can use tools like Poetry to create and manage virtual environments. There are many benefits to using Poetry but if all you need is to create virtual environments for your projects, you can also use the built-in venv module.

If you are on a Linux machine (or a Mac), you can create and activate virtual environments like so:

 # Create a virtual environment for the project   python -m venv my_project_env     # Activate the virtual environment   source my_project_env/bin/activate   

If you’re a Windows user, you can check the docs on how to activate the virtual environment. Using virtual environments for each project is, therefore, helpful to keep dependencies isolated and consistent.

2. Add Type Hints for Maintainability

Because Python is a dynamically typed language, you don't have to specify in the data type for the variables that you create. However, you can add type hints—indicating the expected data type—to make your code more maintainable.

Let’s take an example of a function that calculates the mean of a numerical feature in a dataset with appropriate type annotations:

from typing import List    def calculate_mean(feature: List[float]) -> float:           # Calculate mean of the feature            mean_value = sum(feature) / len(feature)            return mean_value  

Here, the type hints let the user know that the calcuate_mean function takes in a list of floating point numbers and returns a floating-point value.

Remember Python does not enforce types at runtime. But you can use mypy or the like to raise errors for invalid types.

3. Model Your Data with Pydantic

Previously we talked about adding type hints to make code more maintainable. This works fine for Python functions. But when working with data from external sources, it's often helpful to model the data by defining classes and fields with expected data type.

You can use built-in dataclasses in Python, but you don’t get data validation support out of the box. With Pydantic, you can model your data and also use its built-in data validation capabilities. To use Pydantic, you can install it along with the email validator using pip:

$ pip install pydantic[email-validator]

Here’s an example of modeling customer data with Pydantic. You can create a model class that inherits from BaseModel and define the various fields and attributes:

from pydantic import BaseModel, EmailStr    class Customer(BaseModel):  	customer_id: int  	name: str  	email: EmailStr  	phone: str  	address: str    # Sample data  customer_data = {  	'customer_id': 1,  	'name': 'John Doe',  	'email': 'john.doe@example.com',  	'phone': '123-456-7890',  	'address': '123 Main St, City, Country'  }    # Create a customer object  customer = Customer(**customer_data)    print(customer)  

You can take this further by adding validation to check if the fields all have valid values. If you need a tutorial on using Pydantic—defining models and validating data—read Pydantic Tutorial: Data Validation in Python Made Simple.

4. Profile Code to Identify Performance Bottlenecks

Profiling code is helpful if you’re looking to optimize your application for performance. In data science projects, you can profile memory usage and execution times depending on the context.

Suppose you're working on a machine learning project where preprocessing a large dataset is a crucial step before training your model. Let's profile a function that applies common preprocessing steps such as standardization:

import numpy as np  import cProfile    def preprocess_data(data):  	# Perform preprocessing steps: scaling and normalization  	scaled_data = (data - np.mean(data)) / np.std(data)  	return scaled_data    # Generate sample data  data = np.random.rand(100)    # Profile preprocessing function  cProfile.run('preprocess_data(data)')  

When you run the script, you should see a similar output:

profiling-output

In this example, we're profiling the preprocess_data() function, which preprocesses sample data. Profiling, in general, helps identify any potential bottlenecks—guiding optimizations to improve performance. Here are tutorials on profiling in Python which you may find helpful:

  • Profiling Python Code Using timeit and cProfile
  • Introduction to Memory Profiling in Python

5. Use NumPy’s Vectorized Operations

For any data processing task, you can always write a Python implementation from scratch. But you may not want to do it when working with large arrays of numbers. For most common operations—which can be formulated as operations on vectors—that you need to perform, you can use NumPy to perform them more efficiently.

Let’s take the following example of element-wise multiplication:

import numpy as np  import timeit    # Set seed for reproducibility  np.random.seed(42)    # Array with 1 million random integers  array1 = np.random.randint(1, 10, size=1000000)    array2 = np.random.randint(1, 10, size=1000000)  

Here are the Python-only and NumPy implementations:

# NumPy vectorized implementation for element-wise multiplication  def elementwise_multiply_numpy(array1, array2):  	return array1 * array2    # Sample operation using Python to perform element-wise multiplication  def elementwise_multiply_python(array1, array2):  	result = []  	for x, y in zip(array1, array2):      	result.append(x * y)  	return result  

Let’s use the timeit function from the timeit module to measure the execution times for the above implementations:

# Measure execution time for NumPy implementation  numpy_execution_time = timeit.timeit(lambda: elementwise_multiply_numpy(array1, array2), number=10) / 10  numpy_execution_time = round(numpy_execution_time, 6)    # Measure execution time for Python implementation  python_execution_time = timeit.timeit(lambda: elementwise_multiply_python(array1, array2), number=10) / 10  python_execution_time = round(python_execution_time, 6)    # Compare execution times  print("NumPy Execution Time:", numpy_execution_time, "seconds")  print("Python Execution Time:", python_execution_time, "seconds")  

We see that the NumPy implementation is ~100 times faster:

Output >>>  NumPy Execution Time: 0.00251 seconds  Python Execution Time: 0.216055 seconds  

Wrapping Up

In this tutorial, we have explored a few Python coding best practices for data science. I hope you found them helpful.

If you are interested in learning Python for data science, check out 5 Free Courses Master Python for Data Science. Happy learning!

Bala Priya C is a developer and technical writer from India. She likes working at the intersection of math, programming, data science, and content creation. Her areas of interest and expertise include DevOps, data science, and natural language processing. She enjoys reading, writing, coding, and coffee! Currently, she's working on learning and sharing her knowledge with the developer community by authoring tutorials, how-to guides, opinion pieces, and more. Bala also creates engaging resource overviews and coding tutorials.

More On This Topic

  • Integrating ChatGPT Into Data Science Workflows: Tips and Best Practices
  • 5 Best Practices for Data Science Team Collaboration
  • 11 Best Practices of Cloud and Data Migration to AWS Cloud
  • Data Visualization Best Practices & Resources for Effective Communication
  • Data Warehousing and ETL Best Practices
  • Best Practices for Building ETLs for ML

Meta Introduces Vision Language Models, Shows Superior Performance Over Traditional CNNs

Smartphones will be obsolete in 10 years, says Meta Chief

Researchers at Meta recently presented ‘An Introduction to Vision-Language Modeling’, to help people better understand the mechanics behind mapping vision to language. The paper includes everything from how VLMs work, how to train them, and approaches to evaluate VLMs.

This approach is more effective than traditional methods such as CNN-based image captioning, RNN and LSTM networks, encoder-decoder models, and object detection techniques. Traditional methods often lack the advanced capabilities of newer VLMs, such as handling complex spatial relationships, integrating diverse data types and scaling to more sophisticated tasks involving detailed contextual interpretations.

Although the work primarily focuses on mapping images to language, it also discusses extending VLMs to videos.

LLMs process and understand human language. Now, people are trying to use similar technology for images and videos too. This new technology is called Vision-Language Models (VLMs).

VLMs can help you navigate places you’ve never been before just by processing visual information, or they can create pictures from a simple text description you provide.

However, language is made up of distinct words and phrases, which are easier for a computer to analyze. Vision, on the other hand, involves processing images or videos, which are much more complex because they contain more detailed information and aren’t made up of simple, separate parts like words.

Recently, the capability of LLMs has expanded from just processing text to also handling images. However, connecting language to vision is still a challenging area. For instance, many existing models have trouble understanding where things are located in an image or counting objects without needing a lot of extra work and additional information.

Many VLMs also lack an understanding of attributes and ordering. They often ignore some part of the input prompt, leading to prompt engineering efforts to produce the result. Some of them can also hallucinate and produce content that is not relevant. Therefore, the development of reliable models remains an active field of research.

The researchers discuss the integration of computer vision and natural language processing through the use of advanced transformer-based techniques and describe four main training strategies VLMs.

The first method, Contrastive training, involves using both positive and negative examples to train models to predict similar representations for the positive pairs while predicting different representations for the negative pairs.

Another method, Masking, conceals parts of an image or words in a text and trains the model to predict the missing pieces. A third strategy utilizes pre-trained components such as existing language models and image encoders, which reduces the computational cost compared to training from scratch.

Lastly, generative training allows models to create new images or captions but are often the most expensive to train. These strategies are often combined in practice, providing an extensive approach to developing VLMs.

Source: Research Paper

Further the research proposes three data-pruning methods for VLMs such as heuristic methods that remove low-quality image-text pairs; bootstrapping approaches that use pretrained VLMs to evaluate and discard image-text pairs with poor multimodal alignment; and strategies designed to produce diverse and balanced datasets.

The paper also focuses on different methods to evaluate VLMs. Visual Question Answering (VQA) is a widely used technique, although its reliance on exact string matching for comparing model outputs with ground truth answers might not fully capture the model’s performance.

Another approach involves reasoning tasks where VLMs choose the most likely caption from a list. Additionally, recent methods include dense human annotations to determine how accurately a model links captions to the appropriate sections of an image.

Lastly, one can use synthetic data to create images in various scenarios to test a VLM’s adaptability to specific changes.

Source: Research Paper

Finally, the researchers establish that mapping vision to language remains a vibrant field of research with various training methods for VLMs, from contrastive to generative approaches. However, the high computational and data costs often pose challenges for researchers, leading many to utilize pre-trained language models or image encoders to facilitate learning across different modalities.

Key factors such as large-scale high-quality images and captions are important for enhancing model performance. Moreover, improving model grounding and alignment with human preferences are also much needed steps to improve a model’s reliability.

While several benchmarks exist to evaluate the vision-linguistic and reasoning capabilities of VLMs, they often have limitations, such as reliance on language priors. Beyond images, video is another critical modality for developing representations, though many challenges remain in effectively leveraging video data. The ongoing research in VLMs continues to address these gaps to improve model reliability and effectiveness.

The post Meta Introduces Vision Language Models, Shows Superior Performance Over Traditional CNNs appeared first on AIM.