-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial metamodel definition #39
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c791446
Initial metamodel definition
prasad-okahu 0dbd54b
Updated metamode format and README
prasad-okahu 987877d
Updated README and moved the map files
prasad-okahu e43381a
Update format for OTEL compatibility
prasad-okahu c7e0be0
Update format for OTEL compatibility and JSON conventions
prasad-okahu ccdef67
Addressed review feedback
prasad-okahu f2ea2a9
Updated input/output/metadata format. Added readme
prasad-okahu 5de2771
Updated input/output/metadata format. Added readme
prasad-okahu 93fab47
Addressed review feedback
prasad-okahu b98f141
Addressed review feedback
prasad-okahu a824354
Added entity json and updated readmes
prasad-okahu 2bae8a1
Merge branch 'main' into metamodel.prasad
prasad-okahu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Monocle metamodel | ||
|
||
## Overview | ||
Monocle metamodel is the way to manage standardization across all supported GenAI component stack. It includes the list of components that Monocle can identify and extract metadata. This help understanding and analyzing the traces from applications that include multiple components and can evolve over time. This is one of core value that Monocle provides to it's user community. | ||
|
||
## Meta model | ||
The Monocle metamodel comprises of three things, | ||
- Entity types, definitions of technology types and supported vendor implementations. | ||
- A JSON format that overlays on top of Open Telemetry tracing format that includes the common attributes for each entity type. | ||
- Map of component menthods to trace with instrumentation methods provided by Monocle. | ||
|
||
### Entity type | ||
The entity type defines the type of GenAI component that Monocle understand. The monocle instrumentation can extract the relevenat information for this entity. There are a fixed set of [entity types](./entity_types.py) that are defined by Monocle out of the box, eg workflow, model etc. As the GenAI landscape evolves, the Monocle community will introduce a new entity type if the current entities won't represent a new technology component. | ||
Each entity types has number of supported technology components that Monocle handles out of the box, eg. LlamaIndex is a supported workflow. Monocle community will continue to expand the breadth of the project by adding more components. | ||
|
||
### Span types | ||
The GenAI application have specific [types of spans](./spans/README.md#span-types-and-events) where diffrent entities integrate. Monocle metamodel defines these types and specifies format for tracing data and metadata generated in such spans. | ||
|
||
### Consistent trace format | ||
Monocle generates [traces](../../../Monocle_User_Guide.md#traces) which comprises of [spans](../../../Monocle_User_Guide.md#spans). Note that Monocle trace is [OpenTelemetry format](https://opentelemetry.io/docs/concepts/signals/traces/) compatible. Each span is essentially a step in the execution that interacts with one of more GenAI technology components. The please refer to the [full spec of the json format](./span_format.json) and a detailed [example](./span_example.json). | ||
The ```attribute``` section of the span includes a list of such entities that are used in that span. | ||
The runtime data and metadata collected during the execution of that span are included in the ```events``` section of the trace (as per the Otel spec). Each entry in the event corrosponds to the entity involved in that trace execution if it has produced any runtime outputs. | ||
Please see the [span format](./spans/README.md) for details. | ||
|
||
### Instrumentation method map | ||
The map dectates what Monocle tracing method is relevant for the a given GenAI tech component method/API. It also specifies the name for that span to set in the trace output. | ||
```python | ||
{ | ||
"package": "llama_index.core.base.base_query_engine", | ||
"object": "BaseQueryEngine", | ||
"method": "query", | ||
"span_name": "llamaindex.query", | ||
"wrapper_package": "wrap_common", | ||
"wrapper_method": "task_wrapper" | ||
} | ||
``` | ||
|
||
## Extending the meta model | ||
Monocle is highly extensible. This section describe when one would need to extend the meta model. Please refer to Monocle [User guide](../../../Monocle_User_Guide.md) and [Contributor guide](../../../Monocle_contributor_guide.md) for detailed steps. | ||
### Trace a new method/API | ||
If you have overloaded an existing functionality in one of the supported components by creating a new function. Monocle doesn't know that this function should be traced, say because it's calling an LLM. You could define a new mapping so Monocle instrumentation can trace this function the say way it handles other LLM invocation functions. | ||
|
||
### Adding a new component provider | ||
Let's say there's a new database that supports vector search capability which is not supported by the Monocle. In this case, first you'll need to add that database under the ``MonocleEntity.VectorDB`` list. Then you'll need to extend the method map and test if the existing Monocle tracing functions has logic to effectively trace the new component. If not, then you might need to implement new method to cover the gap and update the mapping table according. | ||
|
||
### Support new type of entity | ||
If there's new component that can't be mapped to any of the existing entity types, then it'll require extending the metamodel and implement new instrumetation to support it. We recommend you initiate a discussion with Monocle community to add the support. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Monocle Entities | ||
The entity type defines the type of GenAI component that Monocle understand. The monocle instrumentation can extract the relevenat information for this entity. There are a fixed set of [entity types](./entity_types.py) that are defined by Monocle out of the box, eg workflow, model etc. As the GenAI landscape evolves, the Monocle community will introduce a new entity type if the current entities won't represent a new technology component. | ||
|
||
## Entity Types | ||
Following attributes are supported for all entities | ||
| Name | Description | Required | | ||
| - | - | - | | ||
| name | Entity name generated by Monocle | Required | | ||
| type | Monocle Entity type | True | | ||
|
||
### MonocleEntity.Workflow | ||
Workflow ie the core application code. Supported types are - | ||
- generic | ||
- langchain | ||
- llama_index | ||
- haystack | ||
|
||
### MonocleEntity.Model | ||
GenAI models. Supported types are - | ||
- generic | ||
- llm | ||
- embedding | ||
Following attributes are supported for all model type entities | ||
| Name | Description | Required | | ||
| - | - | - | | ||
| model_name | Name of model | True | | ||
|
||
|
||
### MonocleEntity.AppHosting | ||
Application host services where the workflow code is run. Supported types are - | ||
- generic | ||
- aws_lambda | ||
- aws_sagemaker | ||
- azure_func | ||
- github_codespace | ||
- azure_mlw | ||
|
||
### MonocleEntity.Inference | ||
The model hosting infrastructure services. Supported types are - | ||
- generic | ||
- nvidia_triton | ||
- openai | ||
- azure_oai | ||
- aws_sagemaker | ||
- aws_bedrock | ||
- hugging_face | ||
|
||
### MonocleEntity.VectorStore | ||
Vector search data stores. Supported types are - | ||
- generic | ||
- chroma | ||
- aws_es | ||
- milvus | ||
- pinecone |
157 changes: 157 additions & 0 deletions
157
src/monocle_apptrace/metamodel/entities/entity_types.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
{ | ||
"description": "Monocle entities represents kinds GenAI technology components and their implementations supported by Monocle", | ||
"monocle_entities": [ | ||
{ | ||
"attributes" : [ | ||
{ | ||
"attribute_name": "name", | ||
"attribute_description": "Monocle entity name", | ||
"required": true | ||
}, | ||
{ | ||
"attribute_name": "type", | ||
"attribute_description": "Monocle entity type", | ||
"required": true | ||
} | ||
], | ||
"entities": [ | ||
{ | ||
"name": "workflow", | ||
"attributes" : [], | ||
"types": [ | ||
{ | ||
"type": "llama_index", | ||
"attributes" : [] | ||
}, | ||
{ | ||
"type": "langchain", | ||
"attributes" : [] | ||
}, | ||
{ | ||
"type": "haystack", | ||
"attributes" : [] | ||
}, | ||
{ | ||
"type": "generic", | ||
"attributes" : [] | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "model", | ||
"attributes" : [ | ||
{ | ||
"attribute_name": "model_name", | ||
"attribute_description": "Model name", | ||
"required": true | ||
} | ||
], | ||
"types": [ | ||
{ | ||
"type": "llm", | ||
"attributes" : [] | ||
}, | ||
{ | ||
"type": "embedding", | ||
"attributes" : [] | ||
}, | ||
{ | ||
"type": "generic", | ||
"attributes" : [] | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "vector_store", | ||
"attributes" : [], | ||
"types": [ | ||
{ | ||
"type": "chroma", | ||
"attributes" : [] | ||
}, | ||
{ | ||
"type": "aws_es", | ||
"attributes" : [] | ||
}, | ||
{ | ||
"type": "milvus", | ||
"attributes" : [] | ||
}, | ||
{ | ||
"type": "pinecone", | ||
"attributes" : [] | ||
}, | ||
{ | ||
"type": "generic", | ||
"attributes" : [] | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "app_hosting", | ||
"attributes" : [], | ||
"types": [ | ||
{ | ||
"type": "aws_lambda", | ||
"attributes" : [] | ||
}, | ||
{ | ||
"type": "aws_sagemaker", | ||
"attributes" : [] | ||
}, | ||
{ | ||
"type": "azure_func", | ||
"attributes" : [] | ||
}, | ||
{ | ||
"type": "azure_mlw", | ||
"attributes" : [] | ||
}, | ||
{ | ||
"type": "github_codespace", | ||
"attributes" : [] | ||
}, | ||
{ | ||
"type": "generic", | ||
"attributes" : [] | ||
} | ||
] | ||
}, | ||
{ | ||
"name": "inference", | ||
"attributes" : [], | ||
"types": [ | ||
{ | ||
"type": "aws_sagemaker", | ||
"attributes" : [] | ||
}, | ||
{ | ||
"type": "aws_bedrock", | ||
"attributes" : [] | ||
}, | ||
{ | ||
"type": "azure_oai", | ||
"attributes" : [] | ||
}, | ||
{ | ||
"type": "openai", | ||
"attributes" : [] | ||
}, | ||
{ | ||
"type": "nvidia_triton", | ||
"attributes" : [] | ||
}, | ||
{ | ||
"type": "hugging_face", | ||
"attributes" : [] | ||
}, | ||
{ | ||
"type": "generic", | ||
"attributes" : [] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Monocle meta model: | ||
# Monocle Entities --> Entity Type --> Entity | ||
|
||
import enum | ||
|
||
class MonocleEntity(enum): | ||
# Supported Workflow/language frameworks | ||
class Workflow(enum): | ||
generic = 0 | ||
langchain = 1 | ||
llama_index = 2 | ||
haystack = 3 | ||
|
||
# Supported model types | ||
class Model(enum): | ||
generic = 0 | ||
llm = 1 | ||
embedding = 2 | ||
|
||
# Support Vector databases | ||
class VectorStore(enum): | ||
generic = 0 | ||
chroma = 1 | ||
aws_es = 2 | ||
Milvus = 3 | ||
Pinecone = 4 | ||
|
||
# Support application hosting frameworks | ||
class AppHosting(enum): | ||
generic = 0 | ||
aws_lambda = 1 | ||
aws_sagemaker = 2 | ||
azure_func = 3 | ||
github_codespace = 4 | ||
azure_mlw = 5 | ||
|
||
# Supported inference infra/services | ||
class Inference(enum): | ||
generic = 0 | ||
nvidia_triton = 1 | ||
openai = 2 | ||
azure_oai = 3 | ||
aws_sagemaker = 4 | ||
aws_bedrock = 5 | ||
hugging_face = 6 | ||
|
||
class SpanType(enum): | ||
internal = 0 | ||
retrieval = 2 | ||
inference = 3 | ||
workflow = 4 |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can all the entity types be small case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to keep the vendor names starting with upper case. Do you have a strong preference all lowercase or if that's the convention generally followed, then we can switch to lower case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AWS
- capital case,Azure
- pascal case,NVIDIA
- capital case,OpenAI
- pascal case,HuggingFace
- pascal caseas type is in our control, we can keep it consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True .. I was trying to keep it consistent with the vendor name/brand, but I see your point. I guess it's better to be consistent here. Will change it all to all lowercase and camel case.