avatarYogesh Haribhau Kulkarni (PhD)

Summary

The webpage discusses the adoption of declarative programming paradigms in machine learning (ML) to simplify the development process and make ML more accessible to non-specialists.

Abstract

The article "Coding for non-coders" emphasizes the integration of declarative programming into machine learning (ML) to address the complexity and specialized expertise typically required for building ML systems. Declarative ML allows developers to specify the desired outcomes rather than the procedural steps, enabling the use of high-level abstractions and reducing the need for manual coding of algorithms and control flows. This approach is championed by internal ML platforms at leading tech companies like Uber, Apple, and Meta, which provide smart defaults, automation, and configurable controls to streamline the ML development process. The benefits of declarative ML include reduced decision overhead, rapid iteration, and increased accessibility for developers with varying skill levels. The article also presents real-world applications of declarative programming in AI, such as chatbot generation and fine-tuning large language models, demonstrating the power of declarative abstractions in removing implementation barriers and allowing domain experts to focus on ML tasks rather than infrastructure.

Opinions

  • The author is an advocate for declarative programming, having applied it in various domains including AI and machine learning.
  • There is a recognition that the current state of ML development involves too many complex decisions, which can be mitigated through automation and smart defaults.
  • The article suggests that focusing solely on developing new ML models without understanding past failures is counterproductive; instead, standard testing and comparisons are recommended.
  • The author believes that silos between specialist teams lead to duplication of work, and that shared code and interfaces can enhance collaboration and reuse.
  • The author posits that most developers lack the specialized expertise required for low-level ML coding, and that abstractions can empower these developers to leverage ML without deep coding knowledge.
  • The opinion is expressed that development cycles for ML systems are too long and can be shortened through automation and abstraction, leading to better quality outcomes more quickly.
  • The author argues that declarative ML systems can democratize access to ML by providing different interfaces for stakeholders with varying levels of expertise.
  • The article conveys that declarative ML systems handle the heavy lifting of building robust and scalable ML pipelines, thus avoiding the reinvention of basic components and allowing developers to focus on machine learning rather than infrastructure issues.
  • The author presents the declarative approach as a means to radically simplify the interfaces for leveraging advanced AI techniques, thereby unlocking AI capabilities to a broader audience.
  • While acknowledging the advantages of declarative programming, such as enhanced readability and modular components, the author also recognizes its limitations, including computational overhead and reduced low-level control.
  • The author is optimistic about the future of AI, believing that declarative abstractions will continue to expand its accessibility and that responsibly putting powerful models into more hands is crucial.

Coding for non-coders

Just specify what you want and enjoy the music

Photo by Steinar Engeland on Unsplash

Machine learning has become integral to software applications over the past decade, but building ML systems requires significant specialized expertise. Declarative programming paradigms for ML aim to make the technology more accessible. In declarative ML, developers specify what they want the system to do rather than the procedural steps to implement it. This approach provides simpler abstractions that open up ML to a wider range of software engineers.

What Is Declarative Programming?

Declarative programming focuses on specifying the logic and desired outcomes of a program rather than step-by-step instructions. It centers on expressions and declarations to define rules that are then interpreted by the system. This contrasts with imperative styles that require manually coding algorithms and control flows. Key traits include:

  • High-level abstractions that hide complex implementation details
  • Immutable data structures
  • Incorporation of domain-specific languages

By separating logic from control flow, declarative programming enables clearer, more maintainable code.

Some key challenges in developing machine learning systems

  • Challenge: Too many decisions to get right. Building ML models involves lots of complex choices that can go wrong. Solution: Defaults and automation to guide developers, instead of difficult manual tuning.
  • Challenge: Focusing too much on new models without improving old ones. Teams build new models without evaluating why old ones failed. Solution: Standard testing and comparisons of models to understand gaps. This allows focusing on data and evaluation rather than coding.
  • Challenge: Silos between specialist teams cause duplication. Disjoint teams like entity disambiguation and intent classification don’t collaborate and duplicate work. Solution: Shared code and interfaces for different components to increase collaboration and reuse.
  • Challenge: Most developers lack ML expertise for low-level coding. Solution: Abstractions so most developers don’t have to do specialized ML coding.
  • Challenge: Development takes too long because of many cycles. Solution: Faster iterations with automation and abstraction to achieve better quality faster.
  • Challenge: Too few people can work directly with complex ML systems. Solution: Different interfaces for more stakeholders to participate and leverage ML.

The core issue is complexity that blocks productivity. The solutions aim to simplify and automate to make ML development more accessible.

Here comes, Declarative ML Systems

Internal ML platforms at tech leaders like Uber, Apple, and Meta pioneered declarative ML systems to empower non-specialists to utilize ML. These platforms allow developers to specify inputs, outputs, and constraints on a model while automating the underlying training and deployment pipeline. Benefits include:

  1. Reduced Decision Overhead: Smart defaults and automation around hyperparameters, model selection, etc. let engineers focus on high-value supervision.
  2. Rapid Iteration: Higher abstractions and automation accelerate each cycle to achieve higher quality faster.
  3. Accessibility: Enables usage across skill levels with configurable controls.

In essence, declarative ML separates model objectives from the means of implementation, freeing developers to iterate without coding pipelines.

Salient tenets

1 — No reinventing basic components. Just specify input and output data to generate a complete ML pipeline. No need to code low-level parts like normalization, tokenization, etc. yourself.

2 — Customize as needed over smart defaults. The system provides good defaults to get started quickly. Additional tweaks like lowering text or adding regularization are simple config changes.

3 — Abstracts away infrastructure hassles. No more wasting time debugging infrastructure issues. Built on top of scalable distributed frameworks, so you focus on the machine learning instead of fighting with CUDA and clusters.

Declarative ML systems handle the heavy lifting of building robust and scalable ML pipelines so developers avoid reinventing the wheel and spending time on dev ops. Smart defaults jumpstart projects while still allowing customization. The goal is minimizing overhead so domain experts can concentrate on the machine learning tasks rather than infrastructure.

My own projects

I have long been an enthusiastic proponent of declarative programming, leveraging it across my work from early on. Originally applying it for geometric modeling applications, I later expanded use into my current focus areas of AI, machine learning, natural language processing, and large language models.

A few examples that demonstrate the power of declarative abstractions

  • Bot for Bot (more details): Enables anyone to generate a custom chatbot application simply by specifying a configuration file with basic parameters like name, data sources, and index locations. The system handles all the complex NLP pipeline and model building automatically.
{
 "APP_NAME": "MyApp",
 "DOCS_INDEX":"/fullpath/to/docs.index", 
 "FAISS_STORE_PKL":"/fullpath/to/faiss_store.pkl",
 "FILES_PATHS": [
 "/fullpath/to/file1.csv",
 "/fullpath/to/file2.txt",
 "/fullpath/to/file3.pdf"
 ]
}
  • Fine-tuning LLMs using Ludwig (more details) Allows fine-tuning large pretrained language models without writing any model code through a declarative yaml configuration. Defines features like model architecture and training data while the underlying platform trains the model.
qna_tuning_config_yaml= yaml.safe_load("""
input_features:
 - name: Question
 type: text
 encoder:
 type: auto_transformer
 pretrained_model_name_or_path: meta-llama/Llama-2–7b-hf
 trainable: false
 preprocessing:
 cache_encoder_embeddings: true
output_features:
 - name: Answer
 type: text
""")

The declarative approach in these projects and others removes the heavy lifting from users so they can concentrate on domains tasks rather than implementation details. By radically simplifying the interfaces to leverage state-of-the-art techniques, declarative programming unlocks advanced AI capabilities to a much broader audience.

Pros and Cons

Declarative programming brings notable advantages but also some limitations in AI:

Pros:

  • Enhances readability and comprehension
  • Concise, intuitive representations
  • Encourages modular, reusable components

Cons:

  • Can introduce computational overhead
  • Limits low-level control and optimization
  • Not suited for all applications

Despite drawbacks for select specialized use cases, declarative techniques will continue expanding AI accessibility.

The future is bright for opening up AI’s immense potential to a broader audience of builders through declarative abstractions. As models become exponentially more powerful, putting them in more hands responsibly is pivotal.

References

Declarative Programming — Lark

Click pic below or visit LinkedIn to know more about the author

Artificial Intelligence
Future
Advice
Declarative Programming
Generative Ai Tools
Recommended from ReadMedium